aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2018-04-03 09:46:11 +1200
committerAldo Cortesi <aldo@corte.si>2018-04-03 09:46:11 +1200
commit7e73e5fa51fb59ee1937bd8f634834bb420ff903 (patch)
tree7f54a527c967a16adee5d53962a37b137ea34930 /test
parent14f461c5d59e95e84658ea43567b3ca9f7d0a108 (diff)
downloadmitmproxy-7e73e5fa51fb59ee1937bd8f634834bb420ff903.tar.gz
mitmproxy-7e73e5fa51fb59ee1937bd8f634834bb420ff903.tar.bz2
mitmproxy-7e73e5fa51fb59ee1937bd8f634834bb420ff903.zip
asyncio: factor out test server startup wait
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/proxy/protocol/test_http2.py4
-rw-r--r--test/mitmproxy/proxy/protocol/test_websocket.py4
-rw-r--r--test/mitmproxy/tservers.py11
3 files changed, 7 insertions, 12 deletions
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):