mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-27 20:43:43 +03:00
Parametrized test
This commit is contained in:
parent
eab2b17d64
commit
8f5762ec5f
|
@ -49,23 +49,27 @@ def test_getcolor():
|
||||||
palette.getcolor("unknown")
|
palette.getcolor("unknown")
|
||||||
|
|
||||||
|
|
||||||
def test_getcolor_not_special():
|
@pytest.mark.parametrize(
|
||||||
im = Image.new("P", (1, 1))
|
"index, palette",
|
||||||
for index, palette in {
|
[
|
||||||
# Test when the palette is not full
|
# Test when the palette is not full
|
||||||
0: ImagePalette.ImagePalette(),
|
(0, ImagePalette.ImagePalette()),
|
||||||
# Test when the palette is full
|
# Test when the palette is full
|
||||||
255: ImagePalette.ImagePalette("RGB", list(range(256)) * 3),
|
(255, ImagePalette.ImagePalette("RGB", list(range(256)) * 3)),
|
||||||
}.items():
|
],
|
||||||
# Do not use transparency index as a new color
|
)
|
||||||
im.info["transparency"] = index
|
def test_getcolor_not_special(index, palette):
|
||||||
index1 = palette.getcolor((0, 0, 0), im)
|
im = Image.new("P", (1, 1))
|
||||||
assert index1 != index
|
|
||||||
|
|
||||||
# Do not use background index as a new color
|
# Do not use transparency index as a new color
|
||||||
im.info["background"] = index1
|
im.info["transparency"] = index
|
||||||
index2 = palette.getcolor((0, 0, 1), im)
|
index1 = palette.getcolor((0, 0, 0), im)
|
||||||
assert index2 not in (index, index1)
|
assert index1 != index
|
||||||
|
|
||||||
|
# Do not use background index as a new color
|
||||||
|
im.info["background"] = index1
|
||||||
|
index2 = palette.getcolor((0, 0, 1), im)
|
||||||
|
assert index2 not in (index, index1)
|
||||||
|
|
||||||
|
|
||||||
def test_file(tmp_path):
|
def test_file(tmp_path):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user