From c93fdbee4f48165de983e81dc3f2f89d9cfffc5e Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 28 Oct 2024 15:10:18 +0000 Subject: [PATCH] coverage++ --- tests/compat.py | 2 +- tests/test_django_watchfiles.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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})