From 2a9d84b75ba7e057793762fa3d4ecd829f952281 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 28 Oct 2024 21:42:39 +0000 Subject: [PATCH] Actually 100% test coverage --- src/django_watchfiles/__init__.py | 4 ++-- tests/test_django_watchfiles.py | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/django_watchfiles/__init__.py b/src/django_watchfiles/__init__.py index 463c8c6..19b05eb 100644 --- a/src/django_watchfiles/__init__.py +++ b/src/django_watchfiles/__init__.py @@ -91,8 +91,8 @@ def tick(self) -> Generator[None]: ) self.watcher.set_roots(roots) - for changes in self.watcher: - for _, path in changes: + for changes in self.watcher: # pragma: no branch + for _, path in changes: # pragma: no cover self.notify_file_changed(Path(path)) yield diff --git a/tests/test_django_watchfiles.py b/tests/test_django_watchfiles.py index c2b7e57..6cfb824 100644 --- a/tests/test_django_watchfiles.py +++ b/tests/test_django_watchfiles.py @@ -98,7 +98,6 @@ def setUp(self): def test_file_filter_watched_file(self): test_txt = self.temp_path / "test.txt" - test_txt.touch() self.reloader.watched_files_set = {test_txt} result = self.reloader.file_filter(Change.modified, str(test_txt)) @@ -107,7 +106,6 @@ def test_file_filter_watched_file(self): def test_file_filter_unwatched_file(self): test_txt = self.temp_path / "test.txt" - test_txt.touch() result = self.reloader.file_filter(Change.modified, str(test_txt)) @@ -156,10 +154,14 @@ def test_file_filter_glob_relative_path_impossible(self): def test_tick(self): test_txt = self.temp_path / "test.txt" - test_txt.touch() - self.reloader.watched_files_set = {test_txt} + self.reloader.extra_files = {test_txt} + + iterator = self.reloader.tick() + result = next(iterator) + assert result is None - self.reloader.tick() + result = self.reloader.file_filter(Change.modified, str(test_txt)) + assert result is True class ReplacedGetReloaderTests(SimpleTestCase):