File tree 2 files changed +11
-7
lines changed
2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 12
12
import pytest
13
13
14
14
import matplotlib as mpl
15
+ from matplotlib import _c_internal_utils
15
16
16
17
17
18
# Minimal smoke-testing of the backends for which the dependencies are
@@ -40,8 +41,8 @@ def _get_testable_interactive_backends():
40
41
]:
41
42
reason = None
42
43
missing = [dep for dep in deps if not importlib .util .find_spec (dep )]
43
- if sys .platform == "linux" and not os . environ . get ( "DISPLAY" ):
44
- reason = "$DISPLAY is unset"
44
+ if sys .platform == "linux" and _c_internal_utils . display_is_valid ( ):
45
+ reason = "$DISPLAY and $WAYLAND_DISPLAY are unset"
45
46
elif missing :
46
47
reason = "{} cannot be imported" .format (", " .join (missing ))
47
48
elif backend == 'macosx' and os .environ .get ('TF_BUILD' ):
@@ -276,7 +277,8 @@ def test_lazy_linux_headless():
276
277
import sys
277
278
278
279
# make it look headless
279
- del os.environ['DISPLAY']
280
+ os.environ.pop('DISPLAY', None)
281
+ os.environ.pop('WAYLAND_DISPLAY', None)
280
282
281
283
# we should fast-track to Agg
282
284
import matplotlib.pyplot as plt
Original file line number Diff line number Diff line change 10
10
import pytest
11
11
12
12
import matplotlib as mpl
13
- from matplotlib import _api
13
+ from matplotlib import _api , _c_internal_utils
14
14
import matplotlib .pyplot as plt
15
15
import matplotlib .colors as mcolors
16
16
import numpy as np
@@ -476,7 +476,8 @@ def test_rcparams_reset_after_fail():
476
476
@pytest .mark .skipif (sys .platform != "linux" , reason = "Linux only" )
477
477
def test_backend_fallback_headless (tmpdir ):
478
478
env = {** os .environ ,
479
- "DISPLAY" : "" , "MPLBACKEND" : "" , "MPLCONFIGDIR" : str (tmpdir )}
479
+ "DISPLAY" : "" , "WAYLAND_DISPLAY" : "" ,
480
+ "MPLBACKEND" : "" , "MPLCONFIGDIR" : str (tmpdir )}
480
481
with pytest .raises (subprocess .CalledProcessError ):
481
482
subprocess .run (
482
483
[sys .executable , "-c" ,
@@ -487,8 +488,9 @@ def test_backend_fallback_headless(tmpdir):
487
488
env = env , check = True )
488
489
489
490
490
- @pytest .mark .skipif (sys .platform == "linux" and not os .environ .get ("DISPLAY" ),
491
- reason = "headless" )
491
+ @pytest .mark .skipif (
492
+ sys .platform == "linux" and not _c_internal_utils .display_is_valid (),
493
+ reason = "headless" )
492
494
def test_backend_fallback_headful (tmpdir ):
493
495
pytest .importorskip ("tkinter" )
494
496
env = {** os .environ , "MPLBACKEND" : "" , "MPLCONFIGDIR" : str (tmpdir )}
You can’t perform that action at this time.
0 commit comments