From ae84c4ef9f955d78f0a31ed5fb3d0605e028a126 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 28 Oct 2024 21:59:09 +0000 Subject: [PATCH] test and changelog note --- CHANGELOG.rst | 4 ++++ tests/test_django_watchfiles.py | 8 ++++++++ 2 files changed, 12 insertions(+) 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):