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:43:10 +0200 |
| commit | 7089502b98f80e8dc1c8f6e85fb0620809aec30e (patch) | |
| tree | e32f72e1e55dee96102e0d25cf6f4c568b831b2a /tests/utils_tests | |
| parent | ace0bec804d0bd74e1ecddbe3ea9a8b5b5d0a718 (diff) | |
[2.2.x] 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.
Backport of 480492fe70b0bb7df61c00854dc8535c9d21ba64 from master
Diffstat (limited to 'tests/utils_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 82f7287fa8..56b03d40a6 100644 --- a/tests/utils_tests/test_autoreload.py +++ b/tests/utils_tests/test_autoreload.py @@ -656,6 +656,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()), {}) |
