1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Used addCleanup() in tests where appropriate.

This commit is contained in:
Mariusz Felisiak
2023-12-31 10:01:31 +01:00
committed by GitHub
parent 81ccf92f15
commit d88ec42bd0
37 changed files with 121 additions and 240 deletions

View File

@@ -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)