diff options
| author | Tom Forbes <tom@tomforb.es> | 2019-05-27 12:50:05 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-05-29 09:41:24 +0200 |
| commit | 480492fe70b0bb7df61c00854dc8535c9d21ba64 (patch) | |
| tree | dd663d6cba5c3c1476180dab91ad15004fff1203 /tests | |
| parent | 0344565179527d80990e2247e3be7c04aa8c43c8 (diff) | |
Fixed #30523 -- Fixed updating file modification times on seen files in auto-reloader when using StatReloader.
Previously we updated the file mtimes if the file has not been seen
before - i.e on the first iteration of the loop.
If the mtime has been changed we triggered the notify_file_changed()
method which in all cases except the translations will result in the
process being terminated. To be strictly correct we need to update the
mtime for either branch of the conditional.
Regression in 6754bffa2b2df15a741008aa611c1bb0e8dff22b.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/utils_tests/test_autoreload.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py index 520c5583a4..f130d216cc 100644 --- a/tests/utils_tests/test_autoreload.py +++ b/tests/utils_tests/test_autoreload.py @@ -659,6 +659,16 @@ class StatReloaderTests(ReloaderTests, IntegrationTests): # Shorten the sleep time to speed up tests. self.reloader.SLEEP_TIME = 0.01 + @mock.patch('django.utils.autoreload.StatReloader.notify_file_changed') + def test_tick_does_not_trigger_twice(self, mock_notify_file_changed): + with mock.patch.object(self.reloader, 'watched_files', return_value=[self.existing_file]): + ticker = self.reloader.tick() + next(ticker) + self.increment_mtime(self.existing_file) + next(ticker) + next(ticker) + self.assertEqual(mock_notify_file_changed.call_count, 1) + def test_snapshot_files_ignores_missing_files(self): with mock.patch.object(self.reloader, 'watched_files', return_value=[self.nonexistent_file]): self.assertEqual(dict(self.reloader.snapshot_files()), {}) |
