Skip to content

Commit

Permalink
add typing to image bytes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yay295 committed Mar 11, 2024
1 parent c56c890 commit 12d626a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,22 +1058,24 @@ class TestImageBytes:
)

@pytest.mark.parametrize("mode", image_mode_names_not_bgr)
def test_roundtrip_bytes_constructor(self, mode):
def test_roundtrip_bytes_constructor(self, mode: str):
source_image = hopper(mode)
source_bytes = source_image.tobytes()
copy_image = Image.frombytes(mode, source_image.size, source_bytes)
assert copy_image.tobytes() == source_bytes

@pytest.mark.parametrize("mode", image_mode_names_not_bgr)
def test_roundtrip_bytes_method(self, mode):
def test_roundtrip_bytes_method(self, mode: str):
source_image = hopper(mode)
source_bytes = source_image.tobytes()
copy_image = Image.new(mode, source_image.size)
copy_image.frombytes(source_bytes)
assert copy_image.tobytes() == source_bytes

@pytest.mark.parametrize(("mode", "num_bands", "pixelsize"), image_modes_not_bgr)
def test_pixels_after_getdata_putdata(self, mode, num_bands, pixelsize):
def test_pixels_after_getdata_putdata(
self, mode: str, num_bands: int, pixelsize: int
):
image_byte_size = 2 * 2 * pixelsize
start_bytes = self.sample_bytes[:image_byte_size]
image = Image.frombytes(mode, (2, 2), start_bytes)
Expand Down

0 comments on commit 12d626a

Please sign in to comment.