From 487d904bf253de2f5633f181a168f94086bcd6cb Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Tue, 5 Feb 2019 09:11:54 -0800 Subject: 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. --- tests/logging_tests/tests.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests/logging_tests') diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py index 3ab905eab6..c19bfd7559 100644 --- a/tests/logging_tests/tests.py +++ b/tests/logging_tests/tests.py @@ -439,6 +439,7 @@ class SettingsConfigTest(AdminScriptTestCase): a circular import error. """ def setUp(self): + super().setUp() log_config = """{ 'version': 1, 'handlers': { @@ -450,9 +451,6 @@ class SettingsConfigTest(AdminScriptTestCase): }""" self.write_settings('settings.py', sdict={'LOGGING': log_config}) - def tearDown(self): - self.remove_settings('settings.py') - def test_circular_dependency(self): # validate is just an example command to trigger settings configuration out, err = self.run_manage(['check']) @@ -518,6 +516,7 @@ class SettingsCustomLoggingTest(AdminScriptTestCase): callable in LOGGING_CONFIG (i.e., logging.config.fileConfig). """ def setUp(self): + super().setUp() logging_conf = """ [loggers] keys=root @@ -544,7 +543,6 @@ format=%(message)s def tearDown(self): self.temp_file.close() - self.remove_settings('settings.py') def test_custom_logging(self): out, err = self.run_manage(['check']) -- cgit v1.3