From 81279d2ed65b53c08dd6550fada0eb69c00a1deb Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Fri, 17 Feb 2023 15:02:59 +0000 Subject: [PATCH] reverseContourPen_test: check outputImpliedClosingLine works as expected I looked at this again and got suspicious becuase I noticed that the number of pen commands increased from 4 to 6, whereas I only expected it to be 5 (4+1) in the outputImpliedClosingLine=True case. Turns out we are adding an extra duplicate lineTo right after moveTo, which I think is not correct. --- Tests/pens/reverseContourPen_test.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Tests/pens/reverseContourPen_test.py b/Tests/pens/reverseContourPen_test.py index 3b0dd9b26..c9279da0b 100644 --- a/Tests/pens/reverseContourPen_test.py +++ b/Tests/pens/reverseContourPen_test.py @@ -288,7 +288,13 @@ def test_reverse_pen_outputImpliedClosingLine(): revpen.lineTo((0, 10)) revpen.lineTo((0, 0)) revpen.closePath() - assert len(recpen.value) == 4 + assert recpen.value == [ + ("moveTo", ((0, 0),)), + ("lineTo", ((0, 10),)), + ("lineTo", ((10, 0),)), + # ("lineTo", ((0, 0),)), # implied + ("closePath", ()), + ] recpen = RecordingPen() revpen = ReverseContourPen(recpen, outputImpliedClosingLine=True) @@ -297,7 +303,13 @@ def test_reverse_pen_outputImpliedClosingLine(): revpen.lineTo((0, 10)) revpen.lineTo((0, 0)) revpen.closePath() - assert len(recpen.value) == 6 + assert recpen.value == [ + ("moveTo", ((0, 0),)), + ("lineTo", ((0, 10),)), + ("lineTo", ((10, 0),)), + ("lineTo", ((0, 0),)), # not implied + ("closePath", ()), + ] @pytest.mark.parametrize("contour, expected", TEST_DATA)