From 6447c8ae2256b0e074a04307a748d61f990e98d4 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 6 Jun 2016 13:31:44 -0700 Subject: fix .freeze(), improve tests --- test/pathod/test_language_base.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'test/pathod/test_language_base.py') diff --git a/test/pathod/test_language_base.py b/test/pathod/test_language_base.py index bb1e864b..7c7d8cf9 100644 --- a/test/pathod/test_language_base.py +++ b/test/pathod/test_language_base.py @@ -55,8 +55,15 @@ class TestTokValueLiteral: v = base.TokValueLiteral("f\x00oo") assert v.spec() == repr(v) == r"'f\x00oo'" - v = base.TokValueLiteral("\"") - assert v.spec() == repr(v) == '\'"\'' + v = base.TokValueLiteral('"') + assert v.spec() == repr(v) == """ '"' """.strip() + + # While pyparsing has a escChar argument for QuotedString, + # escChar only performs scapes single-character escapes and does not work for e.g. r"\x02". + # Thus, we cannot use that option, which means we cannot have single quotes in strings. + # To fix this, we represent single quotes as r"\x07". + v = base.TokValueLiteral("'") + assert v.spec() == r"'\x27'" def roundtrip(self, spec): e = base.TokValueLiteral.expr() -- cgit v1.2.3