aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/script/test_reloader.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/mitmproxy/script/test_reloader.py b/test/mitmproxy/script/test_reloader.py
new file mode 100644
index 00000000..af0ab88f
--- /dev/null
+++ b/test/mitmproxy/script/test_reloader.py
@@ -0,0 +1,29 @@
+import mock
+from mitmproxy.script.reloader import watch, unwatch
+from test.mitmproxy import tutils
+from threading import Event
+
+
+def test_simple():
+ with tutils.tmpdir():
+ with open("foo.py", "wb"):
+ pass
+
+ script = mock.Mock()
+ script.filename = "foo.py"
+
+ e = Event()
+
+ def _onchange():
+ e.set()
+
+ watch(script, _onchange)
+ with tutils.raises("already observed"):
+ watch(script, _onchange)
+
+ with open("foo.py", "ab") as f:
+ f.write(".")
+
+ assert e.wait(10)
+
+ unwatch(script)