8000 MNT: simplify the sub-process test code · matplotlib/matplotlib@bbbe8d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit bbbe8d2

Browse files
committed
MNT: simplify the sub-process test code
1 parent 3f14f74 commit bbbe8d2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/matplotlib/tests/test_backend_tk.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@ def _isolated_tk_test(success_count, func=None):
2828
if "MPL_TEST_ESCAPE_HATCH" in os.environ:
2929
return func
3030

31+
@pytest.mark.skipif(
32+
importlib.util.find_spec('tkinter'),
33+
reason="missing tkinter"
34+
)
35+
@pytest.mark.skipif(
36+
sys.platform == "linux" and not _c_internal_utils.display_is_valid(),
37+
reason="$DISPLAY and $WAYLAND_DISPLAY are unset"
38+
)
3139
@functools.wraps(func)
3240
def test_func():
33-
if (sys.platform == "linux" and
34-
not _c_internal_utils.display_is_valid()):
35-
pytest.skip("$DISPLAY and $WAYLAND_DISPLAY are unset")
36-
elif not importlib.util.find_spec('tkinter'):
37-
pytest.skip("missing tkinter")
41+
# even if the package exists, may not actually be importable this can
42+
# be the case on some CI systems.
43+
pytest.importorskip('tkinter')
3844
try:
3945
proc = subprocess_run_helper(
4046
func, timeout=_test_timeout,

0 commit comments

Comments
 (0)
0