mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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:
@@ -155,14 +155,12 @@ class CustomTestRunnerOptionsSettingsTests(AdminScriptTestCase):
|
||||
through a settings file.
|
||||
"""
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
settings = {
|
||||
'TEST_RUNNER': '\'test_runner.runner.CustomOptionsTestRunner\'',
|
||||
}
|
||||
self.write_settings('settings.py', sdict=settings)
|
||||
|
||||
def tearDown(self):
|
||||
self.remove_settings('settings.py')
|
||||
|
||||
def test_default_options(self):
|
||||
args = ['test', '--settings=test_project.settings']
|
||||
out, err = self.run_django_admin(args)
|
||||
@@ -195,11 +193,9 @@ class CustomTestRunnerOptionsCmdlineTests(AdminScriptTestCase):
|
||||
using --testrunner.
|
||||
"""
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.write_settings('settings.py')
|
||||
|
||||
def tearDown(self):
|
||||
self.remove_settings('settings.py')
|
||||
|
||||
def test_testrunner_option(self):
|
||||
args = [
|
||||
'test', '--testrunner', 'test_runner.runner.CustomOptionsTestRunner',
|
||||
@@ -228,11 +224,9 @@ class CustomTestRunnerOptionsCmdlineTests(AdminScriptTestCase):
|
||||
|
||||
class Ticket17477RegressionTests(AdminScriptTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.write_settings('settings.py')
|
||||
|
||||
def tearDown(self):
|
||||
self.remove_settings('settings.py')
|
||||
|
||||
def test_ticket_17477(self):
|
||||
"""'manage.py help test' works after r16352."""
|
||||
args = ['help', 'test']
|
||||
|
||||
Reference in New Issue
Block a user