Skip to content

Commit 2bfba7c

Browse files
committed
Fix headless tests on Wayland.
Since #17396, backends now check for Wayland settings as part of headless detection. However, the headless tests do not override those settings. When running on Wayland, they thus think the display exists when they are not supposed to.
1 parent 440af79 commit 2bfba7c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 4 additions & 2 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,8 @@ 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 _c_internal_utils.display_is_valid():
45+
reason = "$DISPLAY and $WAYLAND_DISPLAY are unset"
4546
elif missing:
4647
reason = "{} cannot be imported".format(", ".join(missing))
4748
elif backend == 'macosx' and os.environ.get('TF_BUILD'):
@@ -277,6 +278,7 @@ def test_lazy_linux_headless():
277278
278279
# make it look headless
279280
del os.environ['DISPLAY']
281+
del os.environ['WAYLAND_DISPLAY']
280282
281283
# we should fast-track to Agg
282284
import matplotlib.pyplot as plt

lib/matplotlib/tests/test_rcparams.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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,10 @@ 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
493+
not os.environ.get("DISPLAY") and not os.environ.get("WAYLAND_DISPLAY"),
494+
reason="headless")
492495
def test_backend_fallback_headful(tmpdir):
493496
pytest.importorskip("tkinter")
494497
env = {**os.environ, "MPLBACKEND": "", "MPLCONFIGDIR": str(tmpdir)}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy