Used context manager version of tempfile.TemporaryDirectory() in utils_tests.test_autoreload.
This commit is contained in:
parent
83f55aafdd
commit
e1e4fd707f
|
@ -173,27 +173,25 @@ class TestChildArguments(SimpleTestCase):
|
||||||
|
|
||||||
@mock.patch('sys.warnoptions', [])
|
@mock.patch('sys.warnoptions', [])
|
||||||
def test_exe_fallback(self):
|
def test_exe_fallback(self):
|
||||||
tmpdir = tempfile.TemporaryDirectory()
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
self.addCleanup(tmpdir.cleanup)
|
exe_path = Path(tmpdir) / 'django-admin.exe'
|
||||||
exe_path = Path(tmpdir.name) / 'django-admin.exe'
|
exe_path.touch()
|
||||||
exe_path.touch()
|
with mock.patch('sys.argv', [exe_path.with_suffix(''), 'runserver']):
|
||||||
with mock.patch('sys.argv', [exe_path.with_suffix(''), 'runserver']):
|
self.assertEqual(
|
||||||
self.assertEqual(
|
autoreload.get_child_arguments(),
|
||||||
autoreload.get_child_arguments(),
|
[exe_path, 'runserver']
|
||||||
[exe_path, 'runserver']
|
)
|
||||||
)
|
|
||||||
|
|
||||||
@mock.patch('sys.warnoptions', [])
|
@mock.patch('sys.warnoptions', [])
|
||||||
def test_entrypoint_fallback(self):
|
def test_entrypoint_fallback(self):
|
||||||
tmpdir = tempfile.TemporaryDirectory()
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
self.addCleanup(tmpdir.cleanup)
|
script_path = Path(tmpdir) / 'django-admin-script.py'
|
||||||
script_path = Path(tmpdir.name) / 'django-admin-script.py'
|
script_path.touch()
|
||||||
script_path.touch()
|
with mock.patch('sys.argv', [script_path.with_name('django-admin'), 'runserver']):
|
||||||
with mock.patch('sys.argv', [script_path.with_name('django-admin'), 'runserver']):
|
self.assertEqual(
|
||||||
self.assertEqual(
|
autoreload.get_child_arguments(),
|
||||||
autoreload.get_child_arguments(),
|
[sys.executable, script_path, 'runserver']
|
||||||
[sys.executable, script_path, 'runserver']
|
)
|
||||||
)
|
|
||||||
|
|
||||||
@mock.patch('sys.argv', ['does-not-exist', 'runserver'])
|
@mock.patch('sys.argv', ['does-not-exist', 'runserver'])
|
||||||
@mock.patch('sys.warnoptions', [])
|
@mock.patch('sys.warnoptions', [])
|
||||||
|
|
Loading…
Reference in New Issue