File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -125,16 +125,14 @@ def test_atomic_writing_newlines(tmp_path):
125
125
126
126
127
127
async def test_watch_directory (tmp_path ):
128
- stop_event = asyncio .Event ()
129
-
130
128
async def change_dir ():
129
+ # let the watcher start
131
130
await asyncio .sleep (0.1 )
131
+ # add file to directory
132
132
(tmp_path / "file.txt" ).write_text ("foo" )
133
- await asyncio .sleep (0.1 )
134
- stop_event .set ()
135
133
136
134
asyncio .create_task (change_dir ())
137
-
138
- changes = [ change async for change in awatch (tmp_path , stop_event = stop_event )]
139
-
140
- assert changes == [{( Change . added , str ( tmp_path / "file.txt" ))}]
135
+ stop_event = asyncio . Event ()
136
+ async for change in awatch (tmp_path , stop_event = stop_event ):
137
+ assert change == {( Change . added , str ( tmp_path / "file.txt" ))}
138
+ stop_event . set ()
You can’t perform that action at this time.
0 commit comments