fix tests on OSX

This commit is contained in:
Maximilian Hils 2016-03-19 19:19:36 +01:00
parent fb0b17ee93
commit 4be9074b49
1 changed files with 10 additions and 5 deletions

View File

@ -6,7 +6,7 @@ from threading import Event
def test_simple(): def test_simple():
with tutils.tmpdir(): with tutils.tmpdir():
with open("foo.py", "wb"): with open("foo.py", "w"):
pass pass
script = mock.Mock() script = mock.Mock()
@ -21,9 +21,14 @@ def test_simple():
with tutils.raises("already observed"): with tutils.raises("already observed"):
watch(script, _onchange) watch(script, _onchange)
with open("foo.py", "ab") as f: # Some reloaders don't register a change directly after watching, because they first need to initialize.
f.write(".") # To test if watching works at all, we do repeated writes every 100ms.
for _ in range(100):
assert e.wait(10) with open("foo.py", "a") as f:
f.write(".")
if e.wait(0.1):
break
else:
raise AssertionError("No change detected.")
unwatch(script) unwatch(script)