diff --git a/tests/compat.py b/tests/compat.py index 658942a..e934867 100644 --- a/tests/compat.py +++ b/tests/compat.py @@ -19,7 +19,7 @@ def _enter_context(cm: Any, addcleanup: Callable[..., None]) -> Any: try: enter = cls.__enter__ exit = cls.__exit__ - except AttributeError: + except AttributeError: # pragma: no cover raise TypeError( f"'{cls.__module__}.{cls.__qualname__}' object does " f"not support the context manager protocol" diff --git a/tests/test_django_watchfiles.py b/tests/test_django_watchfiles.py index 4a7be22..718a35f 100644 --- a/tests/test_django_watchfiles.py +++ b/tests/test_django_watchfiles.py @@ -1,6 +1,7 @@ from __future__ import annotations import tempfile +import time from pathlib import Path from django.utils import autoreload @@ -33,6 +34,18 @@ def test_stop(self): self.watcher.stop() assert self.watcher.stop_event.is_set() + def test_iter_no_changes(self): + (self.temp_path / "test.txt").touch() + self.watcher.set_roots({self.temp_path}) + iterator = iter(self.watcher) + # flush initial events + next(iterator) + time.sleep(0.1) # 100ms Rust timeout + + changes = next(iterator) + + assert changes == set() + def test_iter_yields_changes(self): (self.temp_path / "test.txt").touch() self.watcher.set_roots({self.temp_path})