aboutsummaryrefslogtreecommitdiffstats
path: root/pathod/test.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-06-02 17:46:37 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-06-02 17:46:37 +1200
commit92decf96dda3704c3a303399e0e7a0920e130b95 (patch)
tree601f11e4176e73f85619b1c68ed000de02f297ee /pathod/test.py
parent14d6e1d2e3aebf11fe63adc8e29cf0b73e9e01ad (diff)
downloadmitmproxy-92decf96dda3704c3a303399e0e7a0920e130b95.tar.gz
mitmproxy-92decf96dda3704c3a303399e0e7a0920e130b95.tar.bz2
mitmproxy-92decf96dda3704c3a303399e0e7a0920e130b95.zip
Add expect_log to the pathod test truss, and use it for last_log
Diffstat (limited to 'pathod/test.py')
-rw-r--r--pathod/test.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/pathod/test.py b/pathod/test.py
index 23b7a5b6..7e597a72 100644
--- a/pathod/test.py
+++ b/pathod/test.py
@@ -1,5 +1,7 @@
from six.moves import cStringIO as StringIO
import threading
+import time
+
from six.moves import queue
import requests
@@ -49,11 +51,23 @@ class Daemon:
def text_log(self):
return self.logfp.getvalue()
+ def expect_log(self, n, timeout=1):
+ l = []
+ start = time.time()
+ while True:
+ l = self.log()
+ print l
+ if time.time() - start >= timeout:
+ return None
+ if len(l) >= n:
+ break
+ return l
+
def last_log(self):
"""
Returns the last logged request, or None.
"""
- l = self.log()
+ l = self.expect_log(1)
if not l:
return None
return l[0]