1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53:23 +00:00

use socketserver.ThreadingTCPServer as a contextmanager

This commit is contained in:
Thomas Grainger
2023-12-15 11:08:31 +00:00
parent fa789e975b
commit bddec2e62a

View File

@@ -39,7 +39,7 @@ class Proxy(http.server.SimpleHTTPRequestHandler):
@pytest.fixture(scope="session")
def proxy_server():
httpd = socketserver.ThreadingTCPServer(("", 0), Proxy)
with socketserver.ThreadingTCPServer(("", 0), Proxy) as httpd:
proxy_process = threading.Thread(target=httpd.serve_forever)
proxy_process.start()
yield "http://{}:{}".format(*httpd.server_address)