diff options
| author | Tim Graham <timograham@gmail.com> | 2013-09-03 13:37:27 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-09-03 13:37:27 -0400 |
| commit | cb98ffe8f45d77a7e892fbb80b47de999062dc74 (patch) | |
| tree | 3e781a30ded349414922d758657c59ba12d9a204 | |
| parent | 3db66b1d65c12a94476017cbcc86e72fd842d29e (diff) | |
Fixed a couple unclosed file warnings in tests
| -rw-r--r-- | tests/file_storage/tests.py | 7 | ||||
| -rw-r--r-- | tests/staticfiles_tests/tests.py | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py index 2a6f602e3e..c09d0ef239 100644 --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -567,9 +567,10 @@ class InconsistentGetImageDimensionsBug(unittest.TestCase): from django.core.files.images import ImageFile img_path = os.path.join(os.path.dirname(upath(__file__)), "test.png") - image = ImageFile(open(img_path, 'rb')) - image_pil = Image.open(img_path) - size_1, size_2 = get_image_dimensions(image), get_image_dimensions(image) + with open(img_path, 'rb') as file: + image = ImageFile(file) + image_pil = Image.open(img_path) + size_1, size_2 = get_image_dimensions(image), get_image_dimensions(image) self.assertEqual(image_pil.size, size_1) self.assertEqual(size_1, size_2) diff --git a/tests/staticfiles_tests/tests.py b/tests/staticfiles_tests/tests.py index 7200037050..b73eea319a 100644 --- a/tests/staticfiles_tests/tests.py +++ b/tests/staticfiles_tests/tests.py @@ -783,10 +783,11 @@ class TestAppStaticStorage(TestCase): os.mkdir(self.search_path) module_path = os.path.join(self.search_path, 'foo_module') os.mkdir(module_path) - open(os.path.join(module_path, '__init__.py'), 'w') + self.init_file = open(os.path.join(module_path, '__init__.py'), 'w') sys.path.append(os.path.abspath(self.search_path)) def tearDown(self): + self.init_file.close() sys.path.remove(os.path.abspath(self.search_path)) shutil.rmtree(self.search_path) |
