]> git.scottworley.com Git - paperdoorknob/blobdiff - paperdoorknob_test.py
fetch: test: Explicitly join webserver thread
[paperdoorknob] / paperdoorknob_test.py
index fafd1c37284c80486f0859aa33c39e0e2728153d..b1d41d493574103bc5b22696d72454a43c33d07e 100644 (file)
@@ -36,11 +36,13 @@ class TestFetch(unittest.TestCase):
     def setUp(self) -> None:
         web_server = HTTPServer(('', 0), FakeGlowficHTTPRequestHandler)
         self._port = web_server.socket.getsockname()[1]
-        threading.Thread(target=web_server.serve_forever).start()
+        self._thread = threading.Thread(target=web_server.serve_forever)
+        self._thread.start()
         self._stop_server = web_server.shutdown
 
     def tearDown(self) -> None:
         self._stop_server()
+        self._thread.join()
 
     def testFetch(self) -> None:
         paperdoorknob.fetch(f"http://localhost:{self._port}", TIMEOUT)