Skip to content

Commit

Permalink
coverage++
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz committed Oct 28, 2024
1 parent e9dbdd9 commit c93fdbe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions tests/test_django_watchfiles.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import tempfile
import time
from pathlib import Path

from django.utils import autoreload
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit c93fdbe

Please sign in to comment.