Skip to content

Commit

Permalink
Actually 100% test coverage (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz authored Oct 28, 2024
1 parent ae727e7 commit c1630a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/django_watchfiles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 7 additions & 5 deletions tests/test_django_watchfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit c1630a4

Please sign in to comment.