mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 17:54:32 +03:00
Failing test for ResourceWarning on Python 3
This commit is contained in:
parent
04c96f6030
commit
77f0608c4e
|
@ -121,13 +121,16 @@ class PillowTestCase(unittest.TestCase):
|
||||||
result = func(*args, **kwargs)
|
result = func(*args, **kwargs)
|
||||||
|
|
||||||
# Verify some things.
|
# Verify some things.
|
||||||
self.assertGreaterEqual(len(w), 1)
|
if warn_class is None:
|
||||||
found = False
|
self.assertEqual(len(w), 0)
|
||||||
for v in w:
|
else:
|
||||||
if issubclass(v.category, warn_class):
|
self.assertGreaterEqual(len(w), 1)
|
||||||
found = True
|
found = False
|
||||||
break
|
for v in w:
|
||||||
self.assertTrue(found)
|
if issubclass(v.category, warn_class):
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
self.assertTrue(found)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def skipKnownBadTest(self, msg=None, platform=None,
|
def skipKnownBadTest(self, msg=None, platform=None,
|
||||||
|
|
|
@ -478,7 +478,6 @@ class TestImage(PillowTestCase):
|
||||||
im = hopper()
|
im = hopper()
|
||||||
self.assertRaises(ValueError, im.remap_palette, None)
|
self.assertRaises(ValueError, im.remap_palette, None)
|
||||||
|
|
||||||
|
|
||||||
def test__new(self):
|
def test__new(self):
|
||||||
from PIL import ImagePalette
|
from PIL import ImagePalette
|
||||||
|
|
||||||
|
@ -496,7 +495,8 @@ class TestImage(PillowTestCase):
|
||||||
self.assertEqual(new_im.size, im.size)
|
self.assertEqual(new_im.size, im.size)
|
||||||
self.assertEqual(new_im.info, base_image.info)
|
self.assertEqual(new_im.info, base_image.info)
|
||||||
if palette_result is not None:
|
if palette_result is not None:
|
||||||
self.assertEqual(new_im.palette.tobytes(), palette_result.tobytes())
|
self.assertEqual(new_im.palette.tobytes(),
|
||||||
|
palette_result.tobytes())
|
||||||
else:
|
else:
|
||||||
self.assertEqual(new_im.palette, None)
|
self.assertEqual(new_im.palette, None)
|
||||||
|
|
||||||
|
@ -505,6 +505,15 @@ class TestImage(PillowTestCase):
|
||||||
_make_new(im, blank_p, ImagePalette.ImagePalette())
|
_make_new(im, blank_p, ImagePalette.ImagePalette())
|
||||||
_make_new(im, blank_pa, ImagePalette.ImagePalette())
|
_make_new(im, blank_pa, ImagePalette.ImagePalette())
|
||||||
|
|
||||||
|
def test_no_resource_warning_on_save(self):
|
||||||
|
# https://github.com/python-pillow/Pillow/issues/835
|
||||||
|
# Arrange
|
||||||
|
test_file = 'Tests/images/hopper.png'
|
||||||
|
|
||||||
|
# Act/Assert
|
||||||
|
with Image.open(test_file) as im:
|
||||||
|
self.assert_warning(None, lambda: im.save('test_img.jpg'))
|
||||||
|
|
||||||
|
|
||||||
class MockEncoder(object):
|
class MockEncoder(object):
|
||||||
pass
|
pass
|
||||||
|
@ -534,5 +543,6 @@ class TestRegistry(PillowTestCase):
|
||||||
('args',),
|
('args',),
|
||||||
extra=('extra',))
|
extra=('extra',))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user