summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/test_imagefield.py13
1 files changed, 3 insertions, 10 deletions
diff --git a/tests/model_fields/test_imagefield.py b/tests/model_fields/test_imagefield.py
index 8bbfee30f2..8c93ed1bdb 100644
--- a/tests/model_fields/test_imagefield.py
+++ b/tests/model_fields/test_imagefield.py
@@ -55,20 +55,13 @@ class ImageFieldTestMixin(SerializeMixin):
if os.path.exists(temp_storage_dir):
shutil.rmtree(temp_storage_dir)
os.mkdir(temp_storage_dir)
-
+ self.addCleanup(shutil.rmtree, temp_storage_dir)
file_path1 = os.path.join(os.path.dirname(__file__), "4x8.png")
self.file1 = self.File(open(file_path1, "rb"), name="4x8.png")
-
+ self.addCleanup(self.file1.close)
file_path2 = os.path.join(os.path.dirname(__file__), "8x4.png")
self.file2 = self.File(open(file_path2, "rb"), name="8x4.png")
-
- def tearDown(self):
- """
- Removes temp directory and all its contents.
- """
- self.file1.close()
- self.file2.close()
- shutil.rmtree(temp_storage_dir)
+ self.addCleanup(self.file2.close)
def check_dimensions(self, instance, width, height, field_name="mugshot"):
"""