File tree 1 file changed +6
-19
lines changed
1 file changed +6
-19
lines changed Original file line number Diff line number Diff line change @@ -127,29 +127,16 @@ def test_atomic_writing_newlines(tmp_path):
127
127
async def test_watch_directory (tmp_path ):
128
128
stop_event = asyncio .Event ()
129
129
130
- async def stop_soon ():
131
- await asyncio .sleep (0.4 )
132
- stop_event .set ()
133
-
134
130
async def change_dir ():
135
131
await asyncio .sleep (0.1 )
136
- (tmp_path / "file0 " ).write_text ("foo" )
132
+ (tmp_path / "file.txt " ).write_text ("foo" )
137
133
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 ()
142
135
143
- tasks = [ asyncio .create_task (stop_soon ()), asyncio . create_task ( change_dir ())]
136
+ task = asyncio .create_task (change_dir ())
144
137
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 )]
148
139
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" ))}]
154
141
155
- await asyncio . gather ( * tasks )
142
+ await task
You can’t perform that action at this time.
0 commit comments