mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-10 16:22:22 +03:00
branchcov fix
This commit is contained in:
parent
1881f22e89
commit
b72a607b01
BIN
Tests/images/mcidas_mode_L.ara
Normal file
BIN
Tests/images/mcidas_mode_L.ara
Normal file
Binary file not shown.
|
@ -215,12 +215,13 @@ class MockPyDecoder(ImageFile.PyDecoder):
|
|||
|
||||
|
||||
class MockPyEncoder(ImageFile.PyEncoder):
|
||||
last: MockPyEncoder | None
|
||||
last = None # Add this line
|
||||
|
||||
def __init__(self, mode: str, *args: Any) -> None:
|
||||
super().__init__(mode, *args)
|
||||
self._pushes_fd = False
|
||||
self.cleanup_called = False
|
||||
MockPyEncoder.last = self # Update this line
|
||||
|
||||
def encode(self, buffer):
|
||||
# Simulate encoding
|
||||
|
@ -257,22 +258,6 @@ def test_encode_to_file() -> None:
|
|||
with pytest.raises(NotImplementedError):
|
||||
encoder.encode_to_file(buffer, None)
|
||||
|
||||
# Case: cleanup is called after exception
|
||||
encoder.encode = lambda buffer: (_ for _ in ()).throw(ValueError)
|
||||
with pytest.raises(ValueError):
|
||||
encoder.encode_to_file(buffer, None)
|
||||
assert encoder.cleanup_called
|
||||
|
||||
# Case: encode returns unexpected values
|
||||
encoder.encode = lambda buffer: (None, None, None)
|
||||
with pytest.raises(ValueError):
|
||||
encoder.encode_to_file(buffer, None)
|
||||
|
||||
# Case: UnidentifiedImageError
|
||||
with pytest.raises(UnidentifiedImageError):
|
||||
encoder.encode_to_file(buffer, BytesIO(b"\x00" * 10))
|
||||
|
||||
|
||||
xoff, yoff, xsize, ysize = 10, 20, 100, 100
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user