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

TST: fully parameterize test_lazy_linux_headless #22801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions 37 lib/matplotlib/tests/test_backends_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ def _get_testable_interactive_backends():
elif env["MPLBACKEND"].startswith('wx') and sys.platform == 'darwin':
# ignore on OSX because that's currently broken (github #16849)
marks.append(pytest.mark.xfail(reason='github #16849'))
envs.append(pytest.param(env, marks=marks, id=str(env)))
envs.append(
pytest.param(
{**env, 'BACKEND_DEPS': ','.join(deps)},
marks=marks, id=str(env)
)
)
return envs


Expand Down Expand Up @@ -394,32 +399,44 @@ def _lazy_headless():
import os
import sys

backend, deps = sys.argv[1:]
deps = deps.split(',')

# make it look headless
os.environ.pop('DISPLAY', None)
os.environ.pop('WAYLAND_DISPLAY', None)
for dep in deps:
assert dep not in sys.modules

# we should fast-track to Agg
import matplotlib.pyplot as plt
plt.get_backend() == 'agg'
assert 'PyQt5' not in sys.modules
assert plt.get_backend() == 'agg'
for dep in deps:
assert dep not in sys.modules

# make sure we really have pyqt installed
import PyQt5 # noqa
assert 'PyQt5' in sys.modules
# make sure we really have dependencies installed
for dep in deps:
importlib.import_module(dep)
assert dep in sys.modules

# try to switch and make sure we fail with ImportError
try:
plt.switch_backend('qt5agg')
plt.switch_backend(backend)
except ImportError:
...
else:
sys.exit(1)


@pytest.mark.skipif(sys.platform != "linux", reason="this a linux-only test")
@pytest.mark.backend('Qt5Agg', skip_on_importerror=True)
def test_lazy_linux_headless():
proc = _run_helper(_lazy_headless, timeout=_test_timeout, MPLBACKEND="")
@pytest.mark.parametrize("env", _get_testable_interactive_backends())
def test_lazy_linux_headless(env):
proc = _run_helper(
_lazy_headless,
env.pop('MPLBACKEND'), env.pop("BACKEND_DEPS"),
timeout=_test_timeout,
**{**env, 'DISPLAY': '', 'WAYLAND_DISPLAY': ''}
)


def _qApp_warn_impl():
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.