Skip to content

Commit b10ca76

Browse files
committed
Set polling_interval according to when changes are expected
When testing for events in a file watcher, we need to set the `polling_interval` to a value that is small enough to detect the changes we are expecting, otherwise some events could be "merged" if the changes happen faster than the polling interval. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 7aeeb8c commit b10ca76

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/test_file_watcher_integration.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ async def test_file_watcher(tmp_path: pathlib.Path) -> None:
2626
number_of_writes = 0
2727
expected_number_of_writes = 3
2828

29-
file_watcher = FileWatcher(paths=[str(tmp_path)])
29+
file_watcher = FileWatcher(
30+
paths=[str(tmp_path)], polling_interval=timedelta(seconds=0.05)
31+
)
3032
timer = Timer(timedelta(seconds=0.1), SkipMissedAndDrift())
3133

3234
async for selected in select(file_watcher, timer):
@@ -65,6 +67,7 @@ async def test_file_watcher_deletes(tmp_path: pathlib.Path) -> None:
6567
paths=[str(tmp_path)],
6668
event_types={EventType.DELETE},
6769
force_polling=False,
70+
polling_interval=timedelta(seconds=0.05),
6871
)
6972
write_timer = Timer(timedelta(seconds=0.1), SkipMissedAndDrift())
7073
deletion_timer = Timer(timedelta(seconds=0.25), SkipMissedAndDrift())

0 commit comments

Comments
 (0)