Skip to content

Commit

Permalink
Again
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Apr 8, 2022
1 parent 5548742 commit 3874a05
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/services/contents/test_fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,16 @@ def test_atomic_writing_newlines(tmp_path):


async def test_watch_directory(tmp_path):
stop_event = asyncio.Event()
file_path = tmp_path / "file.txt"

async def change_dir():
# let the watcher start
await asyncio.sleep(0.1)
(tmp_path / "file.txt").write_text("foo")
await asyncio.sleep(0.1)
stop_event.set()
# add file to directory
file_path.write_text("foo")

asyncio.create_task(change_dir())

changes = [change async for change in awatch(tmp_path, stop_event=stop_event)]

assert changes == [{(Change.added, str(tmp_path / "file.txt"))}]
stop_event = asyncio.Event()
async for change in awatch(tmp_path, stop_event=stop_event):
assert change == {(Change.added, str(file_path))}
stop_event.set()

0 comments on commit 3874a05

Please sign in to comment.