Used context manager version of tempfile.TemporaryDirectory() in utils_tests.test_autoreload.
@@ -173,9 +173,8 @@ class TestChildArguments(SimpleTestCase):
@mock.patch('sys.warnoptions', [])
def test_exe_fallback(self):
- tmpdir = tempfile.TemporaryDirectory()
- self.addCleanup(tmpdir.cleanup)
- exe_path = Path(tmpdir.name) / 'django-admin.exe'
+ with tempfile.TemporaryDirectory() as tmpdir:
+ exe_path = Path(tmpdir) / 'django-admin.exe'
exe_path.touch()
with mock.patch('sys.argv', [exe_path.with_suffix(''), 'runserver']):
self.assertEqual(
@@ -185,9 +184,8 @@ class TestChildArguments(SimpleTestCase):
@mock.patch('sys.warnoptions', [])
def test_entrypoint_fallback(self):
- tmpdir = tempfile.TemporaryDirectory()
- self.addCleanup(tmpdir.cleanup)
- script_path = Path(tmpdir.name) / 'django-admin-script.py'
+ with tempfile.TemporaryDirectory() as tmpdir:
+ script_path = Path(tmpdir) / 'django-admin-script.py'
script_path.touch()
with mock.patch('sys.argv', [script_path.with_name('django-admin'), 'runserver']):
self.assertEqual(
