Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually 100% test coverage #126

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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