diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b5d1cf2..4ad3e7d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,6 +11,10 @@ Unreleased * Support Python 3.13. +* Fix crashing on non-existent directories, which Django sometimes tries to watch. + + Thanks to baseplate-admin for the report in `Issue #12 `__ and Steven Mapes for the fix in `PR #117 `__. + 0.2.0 (2024-06-19) ------------------ diff --git a/tests/test_django_watchfiles.py b/tests/test_django_watchfiles.py index 6cfb824..c14e5b6 100644 --- a/tests/test_django_watchfiles.py +++ b/tests/test_django_watchfiles.py @@ -163,6 +163,14 @@ def test_tick(self): result = self.reloader.file_filter(Change.modified, str(test_txt)) assert result is True + def test_tick_non_existent_directory_watched(self): + does_not_exist = self.temp_path / "nope" + self.reloader.watch_dir(does_not_exist, "*.txt") + + iterator = self.reloader.tick() + result = next(iterator) + assert result is None + class ReplacedGetReloaderTests(SimpleTestCase): def test_replaced_get_reloader(self):