Skip to content

Commit

Permalink
100% test coverage (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz authored Oct 28, 2024
1 parent bfe12c8 commit ae727e7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_django_watchfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,27 @@ def test_file_filter_glob_matched(self):

assert result is True

def test_file_filter_glob_multiple_globs_unmatched(self):
self.reloader.watch_dir(self.temp_path, "*.css")
self.reloader.watch_dir(self.temp_path, "*.html")

result = self.reloader.file_filter(
Change.modified, str(self.temp_path / "test.py")
)

assert result is False

def test_file_filter_glob_multiple_dirs_unmatched(self):
self.reloader.watch_dir(self.temp_path, "*.css")
temp_dir2 = self.enterContext(tempfile.TemporaryDirectory())
self.reloader.watch_dir(Path(temp_dir2), "*.html")

result = self.reloader.file_filter(
Change.modified, str(self.temp_path / "test.py")
)

assert result is False

def test_file_filter_glob_relative_path_impossible(self):
temp_dir2 = self.enterContext(tempfile.TemporaryDirectory())

Expand All @@ -133,6 +154,13 @@ def test_file_filter_glob_relative_path_impossible(self):

assert result is False

def test_tick(self):
test_txt = self.temp_path / "test.txt"
test_txt.touch()
self.reloader.watched_files_set = {test_txt}

self.reloader.tick()


class ReplacedGetReloaderTests(SimpleTestCase):
def test_replaced_get_reloader(self):
Expand Down

0 comments on commit ae727e7

Please sign in to comment.