1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed a couple unclosed file warnings in tests

This commit is contained in:
Tim Graham 2013-09-03 13:37:27 -04:00
parent 3db66b1d65
commit cb98ffe8f4
2 changed files with 6 additions and 4 deletions

View File

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

View File

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