1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Refs #32355 -- Used addClassCleanup() in tests.

Inspired by Adam Johnson talk on DjangoCon Europe 2021.
This commit is contained in:
Mariusz Felisiak
2021-06-04 12:53:11 +02:00
committed by GitHub
parent 2e4711c611
commit 213850b4b9
3 changed files with 5 additions and 22 deletions

View File

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