Simplified temporary directory handling in AdminScriptTestCase.

Use tempfile.TemporaryDirectory() in AdminScriptTestCase.setUp()
to create and destroy a temporary directory for each test. It removes
the need for individual tests to delete files.

For test classes that don't use the temporary directory, inherit from
SimpleTestCase.
This commit is contained in:
Jon Dufresne 2019-02-05 09:11:54 -08:00 committed by Tim Graham
parent 099c36d546
commit 487d904bf2
5 changed files with 30 additions and 140 deletions

View file

@ -534,14 +534,12 @@ class ReverseLazySettingsTest(AdminScriptTestCase):
import error.
"""
def setUp(self):
super().setUp()
self.write_settings(
'settings.py',
extra="from django.urls import reverse_lazy\nLOGIN_URL = reverse_lazy('login')",
)
def tearDown(self):
self.remove_settings('settings.py')
def test_lazy_in_settings(self):
out, err = self.run_manage(['check'])
self.assertNoOutput(err)