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

Commit 0dfa854

Browse filesBrowse files
committed
TST: Ensure test_webagg subprocess is terminated
If the final communication times out or asserts, there is nothing to enforce that the subprocess is killed.
1 parent 835220b commit 0dfa854
Copy full SHA for 0dfa854

File tree

1 file changed

+20
-17
lines changed
Filter options

1 file changed

+20
-17
lines changed

‎lib/matplotlib/tests/test_backends_interactive.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backends_interactive.py
+20-17Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -481,24 +481,27 @@ def test_webagg():
481481
inspect.getsource(_test_interactive_impl)
482482
+ "\n_test_interactive_impl()", "{}"],
483483
env={**os.environ, "MPLBACKEND": "webagg", "SOURCE_DATE_EPOCH": "0"})
484-
url = "http://{}:{}".format(
485-
mpl.rcParams["webagg.address"], mpl.rcParams["webagg.port"])
484+
url = f'http://{mpl.rcParams["webagg.address"]}:{mpl.rcParams["webagg.port"]}'
486485
timeout = time.perf_counter() + _test_timeout
487-
while True:
488-
try:
489-
retcode = proc.poll()
490-
# check that the subprocess for the server is not dead
491-
assert retcode is None
492-
conn = urllib.request.urlopen(url)
493-
break
494-
except urllib.error.URLError:
495-
if time.perf_counter() > timeout:
496-
pytest.fail("Failed to connect to the webagg server.")
497-
else:
498-
continue
499-
conn.close()
500-
proc.send_signal(signal.SIGINT)
501-
assert proc.wait(timeout=_test_timeout) == 0
486+
try:
487+
while True:
488+
try:
489+
retcode = proc.poll()
490+
# check that the subprocess for the server is not dead
491+
assert retcode is None
492+
conn = urllib.request.urlopen(url)
493+
break
494+
except urllib.error.URLError:
495+
if time.perf_counter() > timeout:
496+
pytest.fail("Failed to connect to the webagg server.")
497+
else:
498+
continue
499+
conn.close()
500+
proc.send_signal(signal.SIGINT)
501+
assert proc.wait(timeout=_test_timeout) == 0
502+
finally:
503+
if proc.poll() is None:
504+
proc.kill()
502505

503506

504507
def _lazy_headless():

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.