Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b5bc46

Browse files
committed
TST: Wrap urlopen in a context manager as well
Just to be on the safe side that it closes.
1 parent 4890369 commit 6b5bc46

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,14 +497,14 @@ def test_webagg():
497497
retcode = proc.poll()
498498
# check that the subprocess for the server is not dead
499499
assert retcode is None
500-
conn = urllib.request.urlopen(url)
501-
break
500+
with urllib.request.urlopen(url):
501+
# Do nothing; we've just confirmed that we can connect.
502+
break
502503
except urllib.error.URLError:
503504
if time.perf_counter() > timeout:
504505
pytest.fail("Failed to connect to the webagg server.")
505506
else:
506507
continue
507-
conn.close()
508508
proc.send_signal(signal.SIGINT)
509509
assert proc.wait(timeout=_test_timeout) == 0
510510
finally:

0 commit comments

Comments
 (0)