1
+ import functools
1
2
import importlib
2
3
import importlib .util
3
4
import inspect
@@ -52,7 +53,10 @@ def wait_for(self, terminator):
52
53
# PyPI-installable on CI. They are not available for all tested Python
53
54
# versions so we don't fail on missing backends.
54
55
55
- def _get_testable_interactive_backends ():
56
+ @functools .lru_cache
57
+ def _get_available_interactive_backends ():
58
+ _is_linux_and_display_invalid = (sys .platform == "linux" and
59
+ not _c_internal_utils .display_is_valid ())
56
60
envs = []
57
61
for deps , env in [
58
62
* [([qt_api ],
@@ -70,8 +74,7 @@ def _get_testable_interactive_backends():
70
74
]:
71
75
reason = None
72
76
missing = [dep for dep in deps if not importlib .util .find_spec (dep )]
73
- if (sys .platform == "linux" and
74
- not _c_internal_utils .display_is_valid ()):
77
+ if _is_linux_and_display_invalid :
75
78
reason = "$DISPLAY and $WAYLAND_DISPLAY are unset"
76
79
elif missing :
77
80
reason = "{} cannot be imported" .format (", " .join (missing ))
@@ -85,8 +88,7 @@ def _get_testable_interactive_backends():
85
88
reason = "no usable GTK bindings"
86
89
marks = []
87
90
if reason :
88
- marks .append (pytest .mark .skip (
89
- reason = f"Skipping { env } because { reason } " ))
91
+ marks .append (pytest .mark .skip (reason = f"Skipping { env } because { reason } " ))
90
92
elif env ["MPLBACKEND" ].startswith ('wx' ) and sys .platform == 'darwin' :
91
93
# ignore on OSX because that's currently broken (github #16849)
92
94
marks .append (pytest .mark .xfail (reason = 'github #16849' ))
@@ -97,15 +99,17 @@ def _get_testable_interactive_backends():
97
99
):
98
100
marks .append ( # https://github.com/actions/setup-python/issues/649
99
101
pytest .mark .xfail (reason = 'Tk version mismatch on Azure macOS CI' ))
100
- envs .append (
101
- pytest .param (
102
- {** env , 'BACKEND_DEPS' : ',' .join (deps )},
103
- marks = marks , id = str (env )
104
- )
105
- )
102
+ envs .append (({** env , 'BACKEND_DEPS' : ',' .join (deps )}, marks ))
106
103
return envs
107
104
108
105
106
+ def _get_testable_interactive_backends ():
107
+ # We re-create this because some of the callers below might modify the markers.
108
+ return [pytest .param ({** env }, marks = [* marks ],
109
+ id = '-' .join (f'{ k } ={ v } ' for k , v in env .items ()))
110
+ for env , marks in _get_available_interactive_backends ()]
111
+
112
+
109
113
def is_ci_environment ():
110
114
# Common CI variables
111
115
ci_environment_variables = [
0 commit comments