This commit is contained in:
Andrew Murray 2025-04-04 19:10:22 +03:00 committed by GitHub
commit 9704b6ace6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 8 deletions

View File

@ -51,6 +51,9 @@ def test_save(tmp_path: Path) -> None:
def test_handler(tmp_path: Path) -> None:
if BufrStubImagePlugin._handler is not None:
return
class TestHandler(ImageFile.StubHandler):
opened = False
loaded = False

View File

@ -51,6 +51,9 @@ def test_save(tmp_path: Path) -> None:
def test_handler(tmp_path: Path) -> None:
if GribStubImagePlugin._handler is not None:
return
class TestHandler(ImageFile.StubHandler):
opened = False
loaded = False

View File

@ -53,6 +53,9 @@ def test_save() -> None:
def test_handler(tmp_path: Path) -> None:
if Hdf5StubImagePlugin._handler is not None:
return
class TestHandler(ImageFile.StubHandler):
opened = False
loaded = False

View File

@ -53,15 +53,19 @@ def test_render() -> None:
assert_image_equal_tofile(im, "Tests/images/drawing.emf")
class TestHandler(ImageFile.StubHandler):
methodCalled = False
def load(self, im: ImageFile.StubImageFile) -> Image.Image:
return Image.new("RGB", (1, 1))
def save(self, im: Image.Image, fp: IO[bytes], filename: str) -> None:
self.methodCalled = True
def test_register_handler(tmp_path: Path) -> None:
class TestHandler(ImageFile.StubHandler):
methodCalled = False
def load(self, im: ImageFile.StubImageFile) -> Image.Image:
return Image.new("RGB", (1, 1))
def save(self, im: Image.Image, fp: IO[bytes], filename: str) -> None:
self.methodCalled = True
if isinstance(WmfImagePlugin._handler, TestHandler):
return
handler = TestHandler()
original_handler = WmfImagePlugin._handler