Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4ea80d2

Browse filesBrowse files
authored
Merge pull request #19083 from QuLogic/headless-tests
Fix headless tests on Wayland.
2 parents 39737b8 + a4087b0 commit 4ea80d2
Copy full SHA for 4ea80d2

File tree

Expand file treeCollapse file tree

2 files changed

+12
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-7
lines changed

‎lib/matplotlib/tests/test_backends_interactive.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backends_interactive.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pytest
1313

1414
import matplotlib as mpl
15+
from matplotlib import _c_internal_utils
1516

1617

1718
# Minimal smoke-testing of the backends for which the dependencies are
@@ -40,8 +41,9 @@ def _get_testable_interactive_backends():
4041
]:
4142
reason = None
4243
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
45+
not _c_internal_utils.display_is_valid()):
46+
reason = "$DISPLAY and $WAYLAND_DISPLAY are unset"
4547
elif missing:
4648
reason = "{} cannot be imported".format(", ".join(missing))
4749
elif backend == 'macosx' and os.environ.get('TF_BUILD'):
@@ -276,7 +278,8 @@ def test_lazy_linux_headless():
276278
import sys
277279
278280
# make it look headless
279-
del os.environ['DISPLAY']
281+
os.environ.pop('DISPLAY', None)
282+
os.environ.pop('WAYLAND_DISPLAY', None)
280283
281284
# we should fast-track to Agg
282285
import matplotlib.pyplot as plt

‎lib/matplotlib/tests/test_rcparams.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_rcparams.py
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pytest
1111

1212
import matplotlib as mpl
13-
from matplotlib import _api
13+
from matplotlib import _api, _c_internal_utils
1414
import matplotlib.pyplot as plt
1515
import matplotlib.colors as mcolors
1616
import numpy as np
@@ -476,7 +476,8 @@ def test_rcparams_reset_after_fail():
476476
@pytest.mark.skipif(sys.platform != "linux", reason="Linux only")
477477
def test_backend_fallback_headless(tmpdir):
478478
env = {**os.environ,
479-
"DISPLAY": "", "MPLBACKEND": "", "MPLCONFIGDIR": str(tmpdir)}
479+
"DISPLAY": "", "WAYLAND_DISPLAY": "",
480+
"MPLBACKEND": "", "MPLCONFIGDIR": str(tmpdir)}
480481
with pytest.raises(subprocess.CalledProcessError):
481482
subprocess.run(
482483
[sys.executable, "-c",
@@ -487,8 +488,9 @@ def test_backend_fallback_headless(tmpdir):
487488
env=env, check=True)
488489

489490

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")
492494
def test_backend_fallback_headful(tmpdir):
493495
pytest.importorskip("tkinter")
494496
env = {**os.environ, "MPLBACKEND": "", "MPLCONFIGDIR": str(tmpdir)}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.