no need to massage expected test_reverse_point_pen

This commit is contained in:
Cosimo Lupo 2023-02-17 16:51:15 +00:00
parent b64b41f645
commit 4f486ad92e
No known key found for this signature in database
GPG Key ID: DF65A8A5A119C9A8

View File

@ -499,8 +499,8 @@ def test_reverse_pen_outputImpliedClosingLine():
] ]
@pytest.mark.parametrize("contour, expected", [(c, e) for c, _, e in TEST_DATA]) @pytest.mark.parametrize("contour, outputImpliedClosingLine, expected", TEST_DATA)
def test_reverse_point_pen(contour, expected): def test_reverse_point_pen(contour, outputImpliedClosingLine, expected):
from fontTools.ufoLib.pointPen import ( from fontTools.ufoLib.pointPen import (
ReverseContourPointPen, ReverseContourPointPen,
PointToSegmentPen, PointToSegmentPen,
@ -508,24 +508,10 @@ def test_reverse_point_pen(contour, expected):
) )
recpen = RecordingPen() recpen = RecordingPen()
pt2seg = PointToSegmentPen(recpen, outputImpliedClosingLine=True) pt2seg = PointToSegmentPen(recpen, outputImpliedClosingLine)
revpen = ReverseContourPointPen(pt2seg) revpen = ReverseContourPointPen(pt2seg)
seg2pt = SegmentToPointPen(revpen) seg2pt = SegmentToPointPen(revpen)
for operator, operands in contour: for operator, operands in contour:
getattr(seg2pt, operator)(*operands) getattr(seg2pt, operator)(*operands)
# for closed contours that have a lineTo following the moveTo,
# and whose points don't overlap, our current implementation diverges
# from the ReverseContourPointPen as wrapped by ufoLib's pen converters.
# In the latter case, an extra lineTo is added because of
# outputImpliedClosingLine=True. This is redundant but not incorrect,
# as the number of points is the same in both.
if (
contour
and contour[-1][0] == "closePath"
and contour[1][0] == "lineTo"
and contour[1][1] != contour[0][1]
):
expected = expected[:-1] + [("lineTo", contour[0][1])] + expected[-1:]
assert recpen.value == expected assert recpen.value == expected