Skip to content

Commit db610cd

Browse files
committed
Symplify test
1 parent 933313c commit db610cd

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

tests/services/contents/test_fileio.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,29 +127,16 @@ def test_atomic_writing_newlines(tmp_path):
127127
async def test_watch_directory(tmp_path):
128128
stop_event = asyncio.Event()
129129

130-
async def stop_soon():
131-
await asyncio.sleep(0.4)
132-
stop_event.set()
133-
134130
async def change_dir():
135131
await asyncio.sleep(0.1)
136-
(tmp_path / "file0").write_text("foo")
132+
(tmp_path / "file.txt").write_text("foo")
137133
await asyncio.sleep(0.1)
138-
with open(tmp_path / "file0", "a") as f:
139-
f.write(" bar")
140-
await asyncio.sleep(0.1)
141-
(tmp_path / "file0").unlink()
134+
stop_event.set()
142135

143-
tasks = [asyncio.create_task(stop_soon()), asyncio.create_task(change_dir())]
136+
task = asyncio.create_task(change_dir())
144137

145-
changes = []
146-
async for change in awatch(tmp_path, stop_event=stop_event, step=1):
147-
changes.append(change)
138+
changes = [change async for change in awatch(tmp_path, stop_event=stop_event)]
148139

149-
assert changes == [
150-
{(Change.added, str(tmp_path / "file0"))},
151-
{(Change.modified, str(tmp_path / "file0"))},
152-
{(Change.deleted, str(tmp_path / "file0"))},
153-
]
140+
assert changes == [{(Change.added, str(tmp_path / "file.txt"))}]
154141

155-
await asyncio.gather(*tasks)
142+
await task

0 commit comments

Comments
 (0)