summaryrefslogtreecommitdiff
path: root/tests/logging_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-12-31 10:01:31 +0100
committerGitHub <noreply@github.com>2023-12-31 10:01:31 +0100
commitd88ec42bd0a37340c8477a6f20bf26e58bd84735 (patch)
treeabd9422f7fb34a19579a74515ce84d9f472cd226 /tests/logging_tests
parent81ccf92f154c6d9eac3e30bac0aa67574d0ace15 (diff)
Used addCleanup() in tests where appropriate.
Diffstat (limited to 'tests/logging_tests')
-rw-r--r--tests/logging_tests/tests.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py
index c73a3acd6d..20d2852fde 100644
--- a/tests/logging_tests/tests.py
+++ b/tests/logging_tests/tests.py
@@ -579,20 +579,18 @@ args=(sys.stdout,)
[formatter_simple]
format=%(message)s
"""
- self.temp_file = NamedTemporaryFile()
- self.temp_file.write(logging_conf.encode())
- self.temp_file.flush()
+ temp_file = NamedTemporaryFile()
+ temp_file.write(logging_conf.encode())
+ temp_file.flush()
+ self.addCleanup(temp_file.close)
self.write_settings(
"settings.py",
sdict={
"LOGGING_CONFIG": '"logging.config.fileConfig"',
- "LOGGING": 'r"%s"' % self.temp_file.name,
+ "LOGGING": 'r"%s"' % temp_file.name,
},
)
- def tearDown(self):
- self.temp_file.close()
-
def test_custom_logging(self):
out, err = self.run_manage(["check"])
self.assertNoOutput(err)