From c362acb5ce31f0fe0e57da9a423bc5bea9737612 Mon Sep 17 00:00:00 2001 From: Paul O'Leary McCann Date: Wed, 21 Dec 2022 11:47:10 +0900 Subject: [PATCH] Use with for the server This ensures the server is closed correctly. --- spacy/tests/test_misc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spacy/tests/test_misc.py b/spacy/tests/test_misc.py index a465d4bd2..8c3cef8cf 100644 --- a/spacy/tests/test_misc.py +++ b/spacy/tests/test_misc.py @@ -443,7 +443,7 @@ def test_find_available_port(): from wsgiref.simple_server import make_server, demo_app - httpd = make_server(host, port, demo_app) - with pytest.warns(UserWarning, match="already in use"): - found_port = find_available_port(port, host, auto_select_port=True) - assert found_port == port + 1, "Didn't find next port" + with make_server(host, port, demo_app) as httpd: + with pytest.warns(UserWarning, match="already in use"): + found_port = find_available_port(port, host, auto_select_port=True) + assert found_port == port + 1, "Didn't find next port"