diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-03-19 19:19:36 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-03-19 19:19:36 +0100 |
commit | 4be9074b492ec49a4ddd163be72ed835e8feb6f3 (patch) | |
tree | a485316efafc9d58aa1cd665d64e57f1c5df4380 | |
parent | fb0b17ee93f463054c06f035f0d68a4f55c9b2af (diff) | |
download | mitmproxy-4be9074b492ec49a4ddd163be72ed835e8feb6f3.tar.gz mitmproxy-4be9074b492ec49a4ddd163be72ed835e8feb6f3.tar.bz2 mitmproxy-4be9074b492ec49a4ddd163be72ed835e8feb6f3.zip |
fix tests on OSX
-rw-r--r-- | test/mitmproxy/script/test_reloader.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/test/mitmproxy/script/test_reloader.py b/test/mitmproxy/script/test_reloader.py index af0ab88f..0345f6ed 100644 --- a/test/mitmproxy/script/test_reloader.py +++ b/test/mitmproxy/script/test_reloader.py @@ -6,7 +6,7 @@ from threading import Event def test_simple(): with tutils.tmpdir(): - with open("foo.py", "wb"): + with open("foo.py", "w"): pass script = mock.Mock() @@ -21,9 +21,14 @@ def test_simple(): with tutils.raises("already observed"): watch(script, _onchange) - with open("foo.py", "ab") as f: - f.write(".") - - assert e.wait(10) + # Some reloaders don't register a change directly after watching, because they first need to initialize. + # To test if watching works at all, we do repeated writes every 100ms. + for _ in range(100): + with open("foo.py", "a") as f: + f.write(".") + if e.wait(0.1): + break + else: + raise AssertionError("No change detected.") unwatch(script) |