mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-13 05:06:49 +03:00
Fix ResourceWarning emitted during tests
Appeared in the form: ResourceWarning: unclosed file <_io.BufferedReader name='Tests/images/invalid-exif-without-x-resolution.jpg'> Enable all warnings to always display during tests to help catch these warnings earlier.
This commit is contained in:
parent
22a6738a81
commit
2b84221edf
|
@ -640,7 +640,7 @@ class TestFileJpeg(PillowTestCase):
|
|||
|
||||
def test_invalid_exif_x_resolution(self):
|
||||
# When no x or y resolution is defined in EXIF
|
||||
im = Image.open("Tests/images/invalid-exif-without-x-resolution.jpg")
|
||||
with Image.open("Tests/images/invalid-exif-without-x-resolution.jpg") as im:
|
||||
|
||||
# This should return the default, and not a ValueError or
|
||||
# OSError for an unidentified image.
|
||||
|
|
|
@ -231,7 +231,7 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
out = self.tempfile("temp.tiff")
|
||||
im.save(out, tiffinfo=info, compression="raw")
|
||||
|
||||
reloaded = Image.open(out)
|
||||
with Image.open(out) as reloaded:
|
||||
self.assertEqual(max_long, reloaded.tag_v2[41493].numerator)
|
||||
self.assertEqual(1, reloaded.tag_v2[41493].denominator)
|
||||
|
||||
|
@ -243,7 +243,7 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
out = self.tempfile("temp.tiff")
|
||||
im.save(out, tiffinfo=info, compression="raw")
|
||||
|
||||
reloaded = Image.open(out)
|
||||
with Image.open(out) as reloaded:
|
||||
self.assertEqual(max_long, reloaded.tag_v2[41493].numerator)
|
||||
self.assertEqual(1, reloaded.tag_v2[41493].denominator)
|
||||
|
||||
|
@ -260,7 +260,7 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
out = self.tempfile("temp.tiff")
|
||||
im.save(out, tiffinfo=info, compression="raw")
|
||||
|
||||
reloaded = Image.open(out)
|
||||
with Image.open(out) as reloaded:
|
||||
self.assertEqual(numerator, reloaded.tag_v2[37380].numerator)
|
||||
self.assertEqual(denominator, reloaded.tag_v2[37380].denominator)
|
||||
|
||||
|
@ -272,7 +272,7 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
out = self.tempfile("temp.tiff")
|
||||
im.save(out, tiffinfo=info, compression="raw")
|
||||
|
||||
reloaded = Image.open(out)
|
||||
with Image.open(out) as reloaded:
|
||||
self.assertEqual(numerator, reloaded.tag_v2[37380].numerator)
|
||||
self.assertEqual(denominator, reloaded.tag_v2[37380].denominator)
|
||||
|
||||
|
@ -285,7 +285,7 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
out = self.tempfile("temp.tiff")
|
||||
im.save(out, tiffinfo=info, compression="raw")
|
||||
|
||||
reloaded = Image.open(out)
|
||||
with Image.open(out) as reloaded:
|
||||
self.assertEqual(2 ** 31 - 1, reloaded.tag_v2[37380].numerator)
|
||||
self.assertEqual(-1, reloaded.tag_v2[37380].denominator)
|
||||
|
||||
|
@ -298,7 +298,7 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
out = self.tempfile("temp.tiff")
|
||||
im.save(out, tiffinfo=info, compression="raw")
|
||||
|
||||
reloaded = Image.open(out)
|
||||
with Image.open(out) as reloaded:
|
||||
self.assertEqual(reloaded.tag_v2[37000], -60000)
|
||||
|
||||
def test_empty_values(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user