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

Class _WaitForStringPopen

lib/matplotlib/tests/test_backends_interactive.py:25–49  ·  view source on GitHub ↗

A Popen that passes flags that allow triggering KeyboardInterrupt.

Source from the content-addressed store, hash-verified

23
24
25class _WaitForStringPopen(subprocess.Popen):
26 """
27 A Popen that passes flags that allow triggering KeyboardInterrupt.
28 """
29
30 def __init__(self, *args, **kwargs):
31 if sys.platform == 'win32':
32 kwargs['creationflags'] = subprocess.CREATE_NEW_CONSOLE
33 super().__init__(
34 *args, **kwargs,
35 # Force Agg so that each test can switch to its desired backend.
36 env={**os.environ, "MPLBACKEND": "Agg", "SOURCE_DATE_EPOCH": "0"},
37 stdout=subprocess.PIPE, universal_newlines=True)
38
39 def wait_for(self, terminator):
40 """Read until the terminator is reached."""
41 buf = ''
42 while True:
43 c = self.stdout.read(1)
44 if not c:
45 raise RuntimeError(
46 f'Subprocess died before emitting expected {terminator!r}')
47 buf += c
48 if buf.endswith(terminator):
49 return buf
50
51
52# Minimal smoke-testing of the backends for which the dependencies are

Callers 3

test_webaggFunction · 0.85
test_sigintFunction · 0.85

Calls

no outgoing calls

Tested by 3

test_webaggFunction · 0.68
test_sigintFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…