diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-12-31 10:01:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-31 10:01:31 +0100 |
| commit | d88ec42bd0a37340c8477a6f20bf26e58bd84735 (patch) | |
| tree | abd9422f7fb34a19579a74515ce84d9f472cd226 /tests/model_fields | |
| parent | 81ccf92f154c6d9eac3e30bac0aa67574d0ace15 (diff) | |
Used addCleanup() in tests where appropriate.
Diffstat (limited to 'tests/model_fields')
| -rw-r--r-- | tests/model_fields/test_imagefield.py | 13 |
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"): """ |
