aboutsummaryrefslogtreecommitdiffstats
path: root/pathod/test.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-06-03 11:47:07 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-06-03 11:47:07 +1200
commitc5076f5e019b73ec2f6efea5a4bafed90423df8f (patch)
treecf8bcd7ee0da0be6e7a5b3ae673ecc323b0af66c /pathod/test.py
parentc6d15904f3e3a54690637990525da0b53ff1e299 (diff)
downloadmitmproxy-c5076f5e019b73ec2f6efea5a4bafed90423df8f.tar.gz
mitmproxy-c5076f5e019b73ec2f6efea5a4bafed90423df8f.tar.bz2
mitmproxy-c5076f5e019b73ec2f6efea5a4bafed90423df8f.zip
Implement a service connection handler counter, use it in Pathod test suite
Lots of failures, but that's a good thing.
Diffstat (limited to 'pathod/test.py')
-rw-r--r--pathod/test.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/pathod/test.py b/pathod/test.py
index 32b37731..b10e9229 100644
--- a/pathod/test.py
+++ b/pathod/test.py
@@ -7,6 +7,10 @@ from six.moves import queue
from . import pathod
+class TimeoutError(Exception):
+ pass
+
+
class Daemon:
IFACE = "127.0.0.1"
@@ -40,6 +44,17 @@ class Daemon:
def text_log(self):
return self.logfp.getvalue()
+ def wait_for_silence(self, timeout=5):
+ start = time.time()
+ while 1:
+ if time.time() - start >= timeout:
+ raise TimeoutError(
+ "%s service threads still alive" %
+ self.thread.server.counter.count
+ )
+ if self.thread.server.counter.count == 0:
+ return
+
def expect_log(self, n, timeout=5):
l = []
start = time.time()