Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions enable/savage/svg/pathdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ class CaselessPreservingLiteral(CaselessLiteral):

def __init__(self, matchString):
super().__init__(matchString.upper())
self.name = "'%s'" % matchString
self.errmsg = "Expected " + self.name

quoted_name = f"'{matchString}'"
if hasattr(self, "set_name"):
# Only available in pyparsing >= 3
self.set_name(quoted_name)
else:
self.setName(quoted_name)

def parseImpl(self, instring, loc, doActions=True):
test = instring[loc:loc + self.matchLen]
Expand Down
10 changes: 9 additions & 1 deletion enable/savage/svg/tests/test_pathdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@
from enable.savage.svg.pathdata import (
Sequence, closePath, coordinatePair, curve, ellipticalArc, horizontalLine,
lineTo, moveTo, number, quadraticBezierCurveto,
smoothQuadraticBezierCurveto, svg, verticalLine
smoothQuadraticBezierCurveto, svg, verticalLine, CaselessLiteral,
)


class TestCaselessLiteral(unittest.TestCase):
def test_instantiation(self):
# regression test for https://github.com/enthought/enable/issues/887
# observed with pyparsing v >= 3
# we just test that instantiating the class doesnt raise exceptions
CaselessLiteral("test")


class TestNumber(unittest.TestCase):
parser = number
valid = ["1.e10", "1e2", "1e+4", "1e-10", "1.", "1.0", "0.1", ".2"]
Expand Down