diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-06-06 15:59:24 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-06-06 15:59:24 -0700 |
commit | f2f5beb75d60954c88922fc7f483c289cc5d4a7d (patch) | |
tree | c269773538e8c663346191da69e824cbea06d5de /test/pathod/test_language_base.py | |
parent | 7cb7d9ad32c40cff9ceb0e28a5123960fed3638e (diff) | |
parent | 2ee5e8ef0e632545038a72f0cedc0320c59b00ff (diff) | |
download | mitmproxy-f2f5beb75d60954c88922fc7f483c289cc5d4a7d.tar.gz mitmproxy-f2f5beb75d60954c88922fc7f483c289cc5d4a7d.tar.bz2 mitmproxy-f2f5beb75d60954c88922fc7f483c289cc5d4a7d.zip |
Merge branch 'pathod-lang-http'
Diffstat (limited to 'test/pathod/test_language_base.py')
-rw-r--r-- | test/pathod/test_language_base.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/test/pathod/test_language_base.py b/test/pathod/test_language_base.py index 075dc2b8..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() @@ -311,7 +318,7 @@ def test_options_or_value(): def test_integer(): e = base.Integer.expr() v = e.parseString("200")[0] - assert v.string() == "200" + assert v.string() == b"200" assert v.spec() == "200" assert v.freeze({}).value == v.value |