From 7e73e5fa51fb59ee1937bd8f634834bb420ff903 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 3 Apr 2018 09:46:11 +1200 Subject: asyncio: factor out test server startup wait --- test/mitmproxy/proxy/protocol/test_http2.py | 4 ---- test/mitmproxy/proxy/protocol/test_websocket.py | 4 ---- test/mitmproxy/tservers.py | 11 +++++++---- 3 files changed, 7 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/mitmproxy/proxy/protocol/test_http2.py b/test/mitmproxy/proxy/protocol/test_http2.py index 1cc36402..58114904 100644 --- a/test/mitmproxy/proxy/protocol/test_http2.py +++ b/test/mitmproxy/proxy/protocol/test_http2.py @@ -92,10 +92,6 @@ class _Http2TestBase: cls.options = cls.get_options() cls.proxy = tservers.ProxyThread(tservers.TestMaster, cls.options) cls.proxy.start() - while True: - if cls.proxy.tmaster: - break - time.sleep(0.01) @classmethod def teardown_class(cls): diff --git a/test/mitmproxy/proxy/protocol/test_websocket.py b/test/mitmproxy/proxy/protocol/test_websocket.py index f64f500c..e5ed8e9d 100644 --- a/test/mitmproxy/proxy/protocol/test_websocket.py +++ b/test/mitmproxy/proxy/protocol/test_websocket.py @@ -54,10 +54,6 @@ class _WebSocketTestBase: cls.options = cls.get_options() cls.proxy = tservers.ProxyThread(tservers.TestMaster, cls.options) cls.proxy.start() - while True: - if cls.proxy.tmaster: - break - time.sleep(0.01) @classmethod def teardown_class(cls): diff --git a/test/mitmproxy/tservers.py b/test/mitmproxy/tservers.py index d72ca138..7feb90b7 100644 --- a/test/mitmproxy/tservers.py +++ b/test/mitmproxy/tservers.py @@ -121,6 +121,13 @@ class ProxyThread(threading.Thread): self.tmaster.reset(addons) self.tmaster.addons.trigger("tick") + def start(self): + super().start() + while True: + if self.tmaster: + break + time.sleep(0.01) + class ProxyTestBase: # Test Configuration @@ -142,10 +149,6 @@ class ProxyTestBase: cls.options = cls.get_options() cls.proxy = ProxyThread(cls.masterclass, cls.options) cls.proxy.start() - while True: - if cls.proxy.tmaster: - break - time.sleep(0.01) @classmethod def teardown_class(cls): -- cgit v1.2.3