summaryrefslogtreecommitdiff
path: root/tests/file_uploads
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-06-04 12:53:11 +0200
committerGitHub <noreply@github.com>2021-06-04 12:53:11 +0200
commit213850b4b9641bdcb714172999725ec9aa9c9e84 (patch)
treea62f1a50c2b78b2c944b7c7d9167efadf5910d4f /tests/file_uploads
parent2e4711c611896ae6490d3fa3f8d0c506f2ff3673 (diff)
downloaddjango-213850b4b9641bdcb714172999725ec9aa9c9e84.tar.gz
Refs #32355 -- Used addClassCleanup() in tests.
Inspired by Adam Johnson talk on DjangoCon Europe 2021.
Diffstat (limited to 'tests/file_uploads')
-rw-r--r--tests/file_uploads/tests.py12
1 files changed, 2 insertions, 10 deletions
diff --git a/tests/file_uploads/tests.py b/tests/file_uploads/tests.py
index 7bc8d41dac..8b5d1de26f 100644
--- a/tests/file_uploads/tests.py
+++ b/tests/file_uploads/tests.py
@@ -58,11 +58,7 @@ class FileUploadTests(TestCase):
def setUpClass(cls):
super().setUpClass()
os.makedirs(MEDIA_ROOT, exist_ok=True)
-
- @classmethod
- def tearDownClass(cls):
- shutil.rmtree(MEDIA_ROOT)
- super().tearDownClass()
+ cls.addClassCleanup(shutil.rmtree, MEDIA_ROOT)
def test_upload_name_is_validated(self):
candidates = [
@@ -678,11 +674,7 @@ class DirectoryCreationTests(SimpleTestCase):
def setUpClass(cls):
super().setUpClass()
os.makedirs(MEDIA_ROOT, exist_ok=True)
-
- @classmethod
- def tearDownClass(cls):
- shutil.rmtree(MEDIA_ROOT)
- super().tearDownClass()
+ cls.addClassCleanup(shutil.rmtree, MEDIA_ROOT)
def setUp(self):
self.obj = FileModel()