From d88ec42bd0a37340c8477a6f20bf26e58bd84735 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Sun, 31 Dec 2023 10:01:31 +0100 Subject: Used addCleanup() in tests where appropriate. --- tests/cache/tests.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'tests/cache') diff --git a/tests/cache/tests.py b/tests/cache/tests.py index c2a1ebdbb8..e6ebb718f1 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -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): """ -- cgit v1.3