summaryrefslogtreecommitdiff
path: root/tests/utils_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/utils_tests')
-rw-r--r--tests/utils_tests/test_autoreload.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py
index 130f5c8c2a..da375c0f32 100644
--- a/tests/utils_tests/test_autoreload.py
+++ b/tests/utils_tests/test_autoreload.py
@@ -252,3 +252,28 @@ class ResetTranslationsTests(SimpleTestCase):
self.assertEqual(trans_real._translations, {})
self.assertIsNone(trans_real._default)
self.assertIsInstance(trans_real._active, _thread._local)
+
+
+class RestartWithReloaderTests(SimpleTestCase):
+ executable = '/usr/bin/python'
+
+ def patch_autoreload(self, argv):
+ patch_call = mock.patch('django.utils.autoreload.subprocess.call', return_value=0)
+ patches = [
+ mock.patch('django.utils.autoreload.sys.argv', argv),
+ mock.patch('django.utils.autoreload.sys.executable', self.executable),
+ mock.patch('django.utils.autoreload.sys.warnoptions', ['all']),
+ ]
+ for p in patches:
+ p.start()
+ self.addCleanup(p.stop)
+ mock_call = patch_call.start()
+ self.addCleanup(patch_call.stop)
+ return mock_call
+
+ def test_manage_py(self):
+ argv = ['./manage.py', 'runserver']
+ mock_call = self.patch_autoreload(argv)
+ autoreload.restart_with_reloader()
+ self.assertEqual(mock_call.call_count, 1)
+ self.assertEqual(mock_call.call_args[0][0], [self.executable, '-Wall'] + argv)