diff options
| author | Tom Forbes <tom@tomforb.es> | 2020-07-18 19:42:35 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-07-20 09:41:28 +0200 |
| commit | b830cc02ede9d4f41a574664b76916c8fe41de16 (patch) | |
| tree | 436c8b398f52d0396d0e421c8dc5df1ef33c412d | |
| parent | c7e95dea8077ce927ff500247ebb528b8c0a8d7d (diff) | |
[3.1.x] Used temporary directory in RestartWithReloaderTests.test_manage_py().
Using the current directory can cause a PermissionError.
Backport of 730711e8282893723f993f55d3e3b0c823cfdb9a from master
| -rw-r--r-- | tests/utils_tests/test_autoreload.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py index f4ecb38777..72ae20ac12 100644 --- a/tests/utils_tests/test_autoreload.py +++ b/tests/utils_tests/test_autoreload.py @@ -410,14 +410,17 @@ class RestartWithReloaderTests(SimpleTestCase): return mock_call def test_manage_py(self): - script = Path('manage.py') - script.touch() - self.addCleanup(script.unlink) - 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) + with tempfile.TemporaryDirectory() as temp_dir: + script = Path(temp_dir) / 'manage.py' + script.touch() + argv = [script, '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, + ) def test_python_m_django(self): main = '/usr/lib/pythonX.Y/site-packages/django/__main__.py' |
