mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-29 09:23:11 +03:00
parametrize test_getdata_roundtrip()
This commit is contained in:
parent
9e3209e264
commit
ed073324ce
|
@ -38,20 +38,27 @@ def test_putdata_sanity() -> None:
|
||||||
assert_image_equal(im1, im2)
|
assert_image_equal(im1, im2)
|
||||||
|
|
||||||
|
|
||||||
def test_getdata_roundtrip() -> None:
|
@pytest.mark.parametrize(
|
||||||
def getdata(mode: str) -> tuple[float | tuple[int, ...], int, int]:
|
"mode, first_pixel, data_size",
|
||||||
im = hopper(mode).resize((32, 30), Image.Resampling.NEAREST)
|
(
|
||||||
data = im.getdata()
|
("1", 0, 960),
|
||||||
return data[0], len(data), len(list(data))
|
("L", 17, 960),
|
||||||
|
("I", 17, 960),
|
||||||
assert getdata("1") == (0, 960, 960)
|
("F", 17.0, 960),
|
||||||
assert getdata("L") == (17, 960, 960)
|
("RGB", (11, 13, 52), 960),
|
||||||
assert getdata("I") == (17, 960, 960)
|
("RGBA", (11, 13, 52, 255), 960),
|
||||||
assert getdata("F") == (17.0, 960, 960)
|
("CMYK", (244, 242, 203, 0), 960),
|
||||||
assert getdata("RGB") == ((11, 13, 52), 960, 960)
|
("YCbCr", (16, 147, 123), 960),
|
||||||
assert getdata("RGBA") == ((11, 13, 52, 255), 960, 960)
|
),
|
||||||
assert getdata("CMYK") == ((244, 242, 203, 0), 960, 960)
|
)
|
||||||
assert getdata("YCbCr") == ((16, 147, 123), 960, 960)
|
def test_getdata_roundtrip(
|
||||||
|
mode: str, first_pixel: float | tuple[int, ...], data_size: int
|
||||||
|
) -> None:
|
||||||
|
im = hopper(mode).resize((32, 30), Image.Resampling.NEAREST)
|
||||||
|
data = im.getdata()
|
||||||
|
assert data[0] == first_pixel
|
||||||
|
assert len(data) == data_size
|
||||||
|
assert len(list(data)) == data_size
|
||||||
|
|
||||||
|
|
||||||
def test_putdata_long_integers() -> None:
|
def test_putdata_long_integers() -> None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user