MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _lazy_headless

Function _lazy_headless

lib/matplotlib/tests/test_backends_interactive.py:514–544  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

512
513
514def _lazy_headless():
515 import os
516 import sys
517
518 backend, deps = sys.argv[1:]
519 deps = deps.split(',')
520
521 # make it look headless
522 os.environ.pop('DISPLAY', None)
523 os.environ.pop('WAYLAND_DISPLAY', None)
524 for dep in deps:
525 assert dep not in sys.modules
526
527 # we should fast-track to Agg
528 import matplotlib.pyplot as plt
529 assert plt.get_backend() == 'agg'
530 for dep in deps:
531 assert dep not in sys.modules
532
533 # make sure we really have dependencies installed
534 for dep in deps:
535 importlib.import_module(dep)
536 assert dep in sys.modules
537
538 # try to switch and make sure we fail with ImportError
539 try:
540 plt.switch_backend(backend)
541 except ImportError:
542 pass
543 else:
544 sys.exit(1)
545
546
547@pytest.mark.skipif(sys.platform != "linux", reason="this a linux-only test")

Callers

nothing calls this directly

Calls 1

popMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…