Skip to content

Commit 8e52852

Browse files
committed
Combine tests to check output visually
1 parent b0cf48f commit 8e52852

7 files changed

Lines changed: 19 additions & 60 deletions
455 Bytes
Loading
558 Bytes
Loading
361 Bytes
Loading
-130 Bytes
Binary file not shown.
-265 Bytes
Binary file not shown.
-265 Bytes
Binary file not shown.

Tests/test_imagedraw.py

Lines changed: 19 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,106 +1759,65 @@ def test_incorrectly_ordered_coordinates(xy: tuple[int, int, int, int]) -> None:
17591759
draw.rounded_rectangle(xy)
17601760

17611761

1762-
def test_line_dash() -> None:
1762+
def test_dash_line() -> None:
17631763
# Arrange
17641764
im = Image.new("RGB", (W, H))
17651765
draw = ImageDraw.Draw(im)
17661766

17671767
# Act
1768-
draw.line([(10, 50), (90, 50)], "yellow", 2, dash=(10, 5))
1768+
draw.line([(10, 90), (90, 90)], "green", 2, dash=(10, 5))
1769+
draw.line([(10, 10), (50, 50), (90, 10)], "green", 2, dash=(8, 4))
17691770

17701771
# Assert
1771-
assert_image_equal_tofile(im, "Tests/images/imagedraw_line_dash.png")
1772+
assert_image_equal_tofile(im, "Tests/images/imagedraw_dash_line.png")
17721773

17731774

1774-
def test_line_dash_multi_segment() -> None:
1775-
# Arrange
1776-
im = Image.new("RGB", (W, H))
1777-
draw = ImageDraw.Draw(im)
1778-
1779-
# Act - draw a dashed multi-segment line
1780-
draw.line([(10, 10), (50, 50), (90, 10)], "yellow", 2, dash=(8, 4))
1781-
1782-
# Assert - verify the image is not all black (dashes were drawn)
1783-
assert im.getbbox() is not None
1784-
1785-
1786-
def test_line_dash_empty() -> None:
1787-
im = Image.new("RGB", (W, H))
1788-
draw = ImageDraw.Draw(im)
1789-
1790-
with pytest.raises(ValueError, match="dash must be a non-empty tuple of ints"):
1791-
draw.line([(10, 50), (90, 50)], dash=())
1792-
1793-
1794-
def test_polygon_dash() -> None:
1775+
def test_dash_polygon() -> None:
17951776
# Arrange
17961777
im = Image.new("RGB", (W, H))
17971778
draw = ImageDraw.Draw(im)
17981779

17991780
# Act
18001781
draw.polygon(
1801-
[(10, 10), (90, 10), (90, 90), (10, 90)],
1802-
outline="blue",
1782+
[(10, 10), (90, 10), (10, 90)],
1783+
outline="green",
18031784
width=1,
18041785
dash=(10, 5),
18051786
)
1806-
1807-
# Assert
1808-
assert_image_equal_tofile(im, "Tests/images/imagedraw_polygon_dash.png")
1809-
1810-
1811-
def test_polygon_dash_with_fill() -> None:
1812-
# Dashed polygon with fill should draw fill and dashed outline
1813-
im = Image.new("RGB", (W, H))
1814-
draw = ImageDraw.Draw(im)
1815-
18161787
draw.polygon(
1817-
[(10, 10), (90, 10), (90, 90), (10, 90)],
1788+
[(20, 20), (60, 20), (20, 60)],
18181789
fill="red",
1819-
outline="blue",
1790+
outline="green",
18201791
width=1,
18211792
dash=(10, 5),
18221793
)
18231794

1824-
# Verify center pixel is red (fill) and some edge pixels are blue (outline)
1825-
assert im.getpixel((50, 50)) == (255, 0, 0)
1826-
1827-
1828-
def test_polygon_dash_empty() -> None:
1829-
im = Image.new("RGB", (W, H))
1830-
draw = ImageDraw.Draw(im)
1831-
1832-
with pytest.raises(ValueError, match="dash must be a non-empty tuple of ints"):
1833-
draw.polygon([(10, 10), (90, 10), (90, 90)], dash=())
1795+
# Assert
1796+
assert_image_equal_tofile(im, "Tests/images/imagedraw_dash_polygon.png")
18341797

18351798

1836-
def test_rectangle_dash() -> None:
1799+
def test_dash_rectangle() -> None:
18371800
# Arrange
18381801
im = Image.new("RGB", (W, H))
18391802
draw = ImageDraw.Draw(im)
18401803

18411804
# Act
18421805
draw.rectangle([10, 10, 90, 90], outline="green", width=1, dash=(10, 5))
1806+
draw.rectangle([30, 30, 70, 70], fill="red", outline="green", width=1, dash=(10, 5))
18431807

18441808
# Assert
1845-
assert_image_equal_tofile(im, "Tests/images/imagedraw_rectangle_dash.png")
1809+
assert_image_equal_tofile(im, "Tests/images/imagedraw_dash_rectangle.png")
18461810

18471811

1848-
def test_rectangle_dash_with_fill() -> None:
1849-
# Dashed rectangle with fill should draw fill and dashed outline
1812+
def test_dash_empty() -> None:
18501813
im = Image.new("RGB", (W, H))
18511814
draw = ImageDraw.Draw(im)
18521815

1853-
draw.rectangle([10, 10, 90, 90], fill="red", outline="green", width=1, dash=(10, 5))
1854-
1855-
# Verify center pixel is red (fill)
1856-
assert im.getpixel((50, 50)) == (255, 0, 0)
1857-
1816+
with pytest.raises(ValueError, match="dash must be a non-empty tuple of ints"):
1817+
draw.line([(10, 50), (90, 50)], dash=())
18581818

1859-
def test_rectangle_dash_empty() -> None:
1860-
im = Image.new("RGB", (W, H))
1861-
draw = ImageDraw.Draw(im)
1819+
with pytest.raises(ValueError, match="dash must be a non-empty tuple of ints"):
1820+
draw.polygon([(10, 10), (90, 10), (90, 90)], dash=())
18621821

18631822
with pytest.raises(ValueError, match="dash must be a non-empty tuple of ints"):
18641823
draw.rectangle([10, 10, 90, 90], dash=())

0 commit comments

Comments
 (0)