diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-02-07 04:15:24 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-02-07 04:15:24 +0100 |
commit | 9526c5d56570652400929cc33f8fb36f361eecd6 (patch) | |
tree | 6c25603cbfc366ace56466b96da73cb258263368 /test/test_app.py | |
parent | d07029d575532122f3d1f81141710ba36ca307e0 (diff) | |
download | mitmproxy-9526c5d56570652400929cc33f8fb36f361eecd6.tar.gz mitmproxy-9526c5d56570652400929cc33f8fb36f361eecd6.tar.bz2 mitmproxy-9526c5d56570652400929cc33f8fb36f361eecd6.zip |
fix race conditions in test suite
Diffstat (limited to 'test/test_app.py')
-rw-r--r-- | test/test_app.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test/test_app.py b/test/test_app.py index 1ae81fc7..1046be20 100644 --- a/test/test_app.py +++ b/test/test_app.py @@ -1,6 +1,6 @@ -import mock, socket, os, sys +import mock, socket, os, time from libmproxy import dump -from netlib import certutils +from netlib import certutils, tcp from libpathod.pathoc import Pathoc import tutils @@ -14,9 +14,16 @@ def get_free_port(): class AppTestMixin(object): def request(self, spec): - p = Pathoc(("127.0.0.1", self.port)) - p.connect() - return p.request(spec) + t_start = time.time() + while (time.time() - t_start) < 5: + try: + p = Pathoc(("127.0.0.1", self.port)) + p.connect() # might fail as the server might not be online yet. + return p.request(spec) + except tcp.NetLibError: + time.sleep(0.01) + assert False + def test_basic(self): assert self.request("get:/").status_code == 200 |