Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Tcl / Tk failures for Python 3 Linux 64-bit wheel builds #8679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matthew-brett opened this issue May 29, 2017 · 10 comments
Closed

Tcl / Tk failures for Python 3 Linux 64-bit wheel builds #8679

matthew-brett opened this issue May 29, 2017 · 10 comments
Milestone

Comments

@matthew-brett
Copy link
Contributor

For the last several days, for the wheel builds, I am seeing these failures from the Python 3 Linux 64-bit builds:

_____________________________ test_backend[tkagg] ______________________________
[gw0] linux -- Python 3.5.2 /venv/bin/python3.5
backend = 'tkagg'
    @pytest.mark.skipif("DISPLAY" not in os.environ,
                        reason="The DISPLAY environment variable is not set.")
    @pytest.mark.parametrize("backend", _get_available_backends())
    def test_backend(backend):
        environ = os.environ.copy()
        environ["MPLBACKEND"] = backend
        proc = Popen([sys.executable, "-c", _test_script], env=environ)
        # Empirically, 1s is not enough on Travis.
>       assert proc.wait(timeout=5) == 0
E       assert 1 == 0
E        +  where 1 = <bound method Popen.wait of <subprocess.Popen object at 0x7fda8c1f12e8>>(timeout=5)
E        +    where <bound method Popen.wait of <subprocess.Popen object at 0x7fda8c1f12e8>> = <subprocess.Popen object at 0x7fda8c1f12e8>.wait
/venv/lib/python3.5/site-packages/matplotlib/tests/test_backends_interactive.py:53: AssertionError
----------------------------- Captured stderr call -----------------------------
Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/venv/lib/python3.5/site-packages/matplotlib/pyplot.py", line 544, in figure
    **kwargs)
  File "/venv/lib/python3.5/site-packages/matplotlib/backends/backend_tkagg.py", line 80, in new_figure_manager
    return new_figure_manager_given_figure(num, figure)
  File "/venv/lib/python3.5/site-packages/matplotlib/backends/backend_tkagg.py", line 88, in new_figure_manager_given_figure
    window = Tk.Tk(className="matplotlib")
  File "/usr/lib/python3.5/tkinter/__init__.py", line 1871, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
!!!!!!!!!!!! xdist.dsession.Interrupted: stopping after 1 failures !!!!!!!!!!!!!
======== 1 failed, 398 passed, 156 skipped, 5 xfailed in 141.40 seconds ========

See:

Just superficially, it seems that the test decorator should be skipping this test. Any ideas what's going on here?

@dstansby
Copy link
Member

The test was added by #8660

@anntzer
Copy link
Contributor

anntzer commented May 29, 2017

Can you try whether replacing "DISPLAY" not in os.environ by not os.environ.get("DISPLAY") (empty values for environment variables...) would help?

@matthew-brett
Copy link
Contributor Author

Sadly no, it didn't help: https://travis-ci.org/MacPython/matplotlib-wheels/jobs/237287904#L646

I also had a look at the image that it's using for testing - https://hub.docker.com/r/matthewbrett/trusty - DISPLAY is not set.

@matthew-brett
Copy link
Contributor Author

Debug print of python -c "import os; print(not 'DISPLAY' in os.environ)" before tests are run gives True.

https://travis-ci.org/MacPython/matplotlib-wheels/jobs/237292458#L579

@anntzer
Copy link
Contributor

anntzer commented May 29, 2017

What happens with

diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py
index 1b763ea06..f38ff0a6f 100644
--- a/lib/matplotlib/tests/test_backends_interactive.py
+++ b/lib/matplotlib/tests/test_backends_interactive.py
@@ -41,7 +41,7 @@ plt.show()
 """
 
 
[email protected]("DISPLAY" not in os.environ,
[email protected](print("===", repr(os.environ.get("DISPLAY")), "===") or not os.environ.get("DISPLAY"),
                     reason="The DISPLAY environment variable is not set.")
 @pytest.mark.parametrize("backend", _get_available_backends())
 def test_backend(backend):

trying to see if DISPLAY somehow becomes set during test collection...

@matthew-brett
Copy link
Contributor Author

Actually, this assert passes inside the test function:

assert environ.get('DISPLAY') is None

https://travis-ci.org/MacPython/matplotlib-wheels/builds/237425182#L657

I wonder whether the skip decorator is failing to work for all the parametrized backend tests? I mean, maybe the double decoration is the problem?

@pytest.mark.skipif("DISPLAY" not in os.environ,
                    reason="The DISPLAY environment variable is not set.")
@pytest.mark.parametrize("backend", _get_available_backends())
def test_backend(backend):

I tried reversing the decorators without change.

@anntzer
Copy link
Contributor

anntzer commented May 30, 2017

Well the tests to pass on OSX on Travis for us and they do not have an X server (see before_script in .travis.yml) so the skipping must work fine... Still, try something like

diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py
index 1b763ea06..16d276876 100644
--- a/lib/matplotlib/tests/test_backends_interactive.py
+++ b/lib/matplotlib/tests/test_backends_interactive.py
@@ -21,10 +21,12 @@ import pytest
 
 def _get_available_backends():
     return [
-        pytest.mark.skipif(sys.version_info < (3,)
-                           or importlib.util.find_spec(module_name) is None,
-                           reason="Could not import {!r}".format(module_name))(
-                               backend)
+        pytest.mark.skipif(
+            not os.environ.get("DISPLAY")
+            or sys.version_info < (3,)
+            or importlib.util.find_spec(module_name) is None,
+            reason="No $DISPLAY, or could not import {!r}".format(module_name))(
+                backend)
         for module_name, backend in [
                 ("PyQt5", "qt5agg"),
                 ("tkinter", "tkagg"),
@@ -41,8 +43,6 @@ plt.show()
 """
 
 
[email protected]("DISPLAY" not in os.environ,
-                    reason="The DISPLAY environment variable is not set.")
 @pytest.mark.parametrize("backend", _get_available_backends())
 def test_backend(backend):
     environ = os.environ.copy()

@matthew-brett
Copy link
Contributor Author

Yes, that last patch works : https://travis-ci.org/MacPython/matplotlib-wheels/builds/237893723

I guess you could rename the function to _get_testable_interactive_backends.

@anntzer
Copy link
Contributor

anntzer commented May 31, 2017

pr opened

@anntzer
Copy link
Contributor

anntzer commented Jun 10, 2017

I assumed this is closed by #8691, please request a reopen otherwise.

@anntzer anntzer closed this as completed Jun 10, 2017
@QuLogic QuLogic added this to the 2.1 (next point release) milestone Jun 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants