mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Added DeferredError to _fp
This commit is contained in:
parent
f18688e84e
commit
e62449f94c
|
@ -637,6 +637,15 @@ def test_apng_save_blend(tmp_path):
|
|||
assert im.getpixel((0, 0)) == (0, 255, 0, 255)
|
||||
|
||||
|
||||
def test_seek_after_close():
|
||||
im = Image.open("Tests/images/apng/delay.png")
|
||||
im.seek(1)
|
||||
im.close()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
im.seek(0)
|
||||
|
||||
|
||||
def test_constants_deprecation():
|
||||
for enum, prefix in {
|
||||
PngImagePlugin.Disposal: "APNG_DISPOSE_",
|
||||
|
|
|
@ -46,6 +46,15 @@ def test_closed_file():
|
|||
im.close()
|
||||
|
||||
|
||||
def test_seek_after_close():
|
||||
im = Image.open(animated_test_file)
|
||||
im.seek(1)
|
||||
im.close()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
im.seek(0)
|
||||
|
||||
|
||||
def test_context_manager():
|
||||
with warnings.catch_warnings():
|
||||
with Image.open(static_test_file) as im:
|
||||
|
|
|
@ -46,6 +46,19 @@ def test_closed_file():
|
|||
im.close()
|
||||
|
||||
|
||||
def test_seek_after_close():
|
||||
im = Image.open("Tests/images/iss634.gif")
|
||||
im.load()
|
||||
im.close()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
im.is_animated
|
||||
with pytest.raises(ValueError):
|
||||
im.n_frames
|
||||
with pytest.raises(ValueError):
|
||||
im.seek(1)
|
||||
|
||||
|
||||
def test_context_manager():
|
||||
with warnings.catch_warnings():
|
||||
with Image.open(TEST_GIF) as im:
|
||||
|
|
|
@ -48,6 +48,14 @@ def test_closed_file():
|
|||
im.close()
|
||||
|
||||
|
||||
def test_seek_after_close():
|
||||
im = Image.open(test_files[0])
|
||||
im.close()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
im.seek(1)
|
||||
|
||||
|
||||
def test_context_manager():
|
||||
with warnings.catch_warnings():
|
||||
with Image.open(test_files[0]) as im:
|
||||
|
|
|
@ -70,6 +70,15 @@ class TestFileTiff:
|
|||
im.load()
|
||||
im.close()
|
||||
|
||||
def test_seek_after_close(self):
|
||||
im = Image.open("Tests/images/multipage.tiff")
|
||||
im.close()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
im.n_frames
|
||||
with pytest.raises(ValueError):
|
||||
im.seek(1)
|
||||
|
||||
def test_context_manager(self):
|
||||
with warnings.catch_warnings():
|
||||
with Image.open("Tests/images/multipage.tiff") as im:
|
||||
|
|
|
@ -547,7 +547,7 @@ class Image:
|
|||
if getattr(self, "_fp", False):
|
||||
if self._fp != self.fp:
|
||||
self._fp.close()
|
||||
self._fp = None
|
||||
self._fp = DeferredError(ValueError("Operation on closed image"))
|
||||
if self.fp:
|
||||
self.fp.close()
|
||||
self.fp = None
|
||||
|
@ -568,7 +568,7 @@ class Image:
|
|||
if getattr(self, "_fp", False):
|
||||
if self._fp != self.fp:
|
||||
self._fp.close()
|
||||
self._fp = None
|
||||
self._fp = DeferredError(ValueError("Operation on closed image"))
|
||||
if self.fp:
|
||||
self.fp.close()
|
||||
self.fp = None
|
||||
|
|
Loading…
Reference in New Issue
Block a user