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

13
tests/cache/tests.py vendored
View File

@@ -1155,11 +1155,7 @@ class DBCacheTests(BaseCacheTests, TransactionTestCase):
# The super calls needs to happen first for the settings override.
super().setUp()
self.create_table()
def tearDown(self):
# The super call needs to happen first because it uses the database.
super().tearDown()
self.drop_table()
self.addCleanup(self.drop_table)
def create_table(self):
management.call_command("createcachetable", verbosity=0)
@@ -2509,12 +2505,9 @@ class CacheMiddlewareTest(SimpleTestCase):
def setUp(self):
self.default_cache = caches["default"]
self.addCleanup(self.default_cache.clear)
self.other_cache = caches["other"]
def tearDown(self):
self.default_cache.clear()
self.other_cache.clear()
super().tearDown()
self.addCleanup(self.other_cache.clear)
def test_constructor(self):
"""