Skip to content

Commit d06c8b3

Browse files
committed
Test drawing a new color onto a dirty palette
1 parent 6a9960e commit d06c8b3

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Tests/test_imagedraw.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,20 @@ def test_sanity() -> None:
6868
draw.rectangle(list(range(4)))
6969

7070

71-
def test_valueerror() -> None:
71+
def test_new_color() -> None:
7272
with Image.open("Tests/images/chi.gif") as im:
7373
draw = ImageDraw.Draw(im)
74+
assert len(im.palette.colors) == 249
75+
76+
# Test drawing a new color onto the palette
7477
draw.line((0, 0), fill=(0, 0, 0))
78+
assert len(im.palette.colors) == 250
79+
assert im.palette.dirty
80+
81+
# Test drawing another new color, now that the palette is dirty
82+
draw.point((0, 0), fill=(1, 0, 0))
83+
assert len(im.palette.colors) == 251
84+
assert im.convert("RGB").getpixel((0, 0)) == (1, 0, 0)
7585

7686

7787
def test_mode_mismatch() -> None:

0 commit comments

Comments
 (0)