summaryrefslogtreecommitdiff
path: root/unitTests.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2019-08-05 00:21:52 -0500
committerPaul McGuire <ptmcg@austin.rr.com>2019-08-05 00:21:52 -0500
commitc45813fdaa1254b1d28a371f357a7856e7443e51 (patch)
tree980ce2e2593a72b99e7fc1ffe3612bb5d671aec8 /unitTests.py
parent897e536d2131c6d07cbc355edb0ed744213c6997 (diff)
downloadpyparsing-git-c45813fdaa1254b1d28a371f357a7856e7443e51.tar.gz
First pass removing Py2 cross-compatibility features
Diffstat (limited to 'unitTests.py')
-rw-r--r--unitTests.py111
1 files changed, 0 insertions, 111 deletions
diff --git a/unitTests.py b/unitTests.py
index 999f2c7..026b007 100644
--- a/unitTests.py
+++ b/unitTests.py
@@ -785,117 +785,6 @@ class CaselessOneOfTest(ParseTestCase):
self.assertEqual("".join(res), "Aa" * 4, "caseless1 CaselessLiteral return failed")
-class AsXMLTest(ParseTestCase):
- def runTest(self):
-
- # test asXML()
-
- aaa = pp.Word("a")("A")
- bbb = pp.Group(pp.Word("b"))("B")
- ccc = pp.Combine(":" + pp.Word("c"))("C")
- g1 = "XXX>&<" + pp.ZeroOrMore(aaa | bbb | ccc)
- teststring = "XXX>&< b b a b b a b :c b a"
- #~ print teststring
- print_("test including all items")
- xml = g1.parseString(teststring).asXML("TEST", namedItemsOnly=False)
- assert xml=="\n".join(["",
- "<TEST>",
- " <ITEM>XXX&gt;&amp;&lt;</ITEM>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <A>a</A>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <A>a</A>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <C>:c</C>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <A>a</A>",
- "</TEST>",
- ]), \
- "failed to generate XML correctly showing all items: \n[" + xml + "]"
- print_("test filtering unnamed items")
- xml = g1.parseString(teststring).asXML("TEST", namedItemsOnly=True)
- assert xml=="\n".join(["",
- "<TEST>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <A>a</A>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <A>a</A>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <C>:c</C>",
- " <B>",
- " <ITEM>b</ITEM>",
- " </B>",
- " <A>a</A>",
- "</TEST>",
- ]), \
- "failed to generate XML correctly, filtering unnamed items: " + xml
-
-class AsXMLTest2(ParseTestCase):
- def runTest(self):
- from pyparsing import Suppress, Optional, CharsNotIn, Combine, ZeroOrMore, Word,\
- Group, Literal, alphas, alphanums, delimitedList, OneOrMore
-
- EndOfLine = Word("\n").setParseAction(lambda s, l, t: [' '])
- whiteSpace=Word('\t ')
- Mexpr = Suppress(Optional(whiteSpace)) + CharsNotIn('\\"\t \n') + Optional(" ") + \
- Suppress(Optional(whiteSpace))
- reducedString = Combine(Mexpr + ZeroOrMore(EndOfLine + Mexpr))
- _bslash = "\\"
- _escapables = "tnrfbacdeghijklmopqsuvwxyz" + _bslash + "'" + '"'
- _octDigits = "01234567"
- _escapedChar = (Word(_bslash, _escapables, exact=2) |
- Word(_bslash, _octDigits, min=2, max=4))
- _sglQuote = Literal("'")
- _dblQuote = Literal('"')
- QuotedReducedString = Combine(Suppress(_dblQuote) + ZeroOrMore(reducedString |
- _escapedChar) + \
- Suppress(_dblQuote)).streamline()
-
- Manifest_string = QuotedReducedString('manifest_string')
-
- Identifier = Word(alphas, alphanums+ '_$')("identifier")
- Index_string = CharsNotIn('\\";\n')
- Index_string.setName('index_string')
- Index_term_list = (
- Group(delimitedList(Manifest_string, delim=',')) | \
- Index_string
- )('value')
-
- IndexKey = Identifier('key')
- IndexKey.setName('key')
- Index_clause = Group(IndexKey + Suppress(':') + Optional(Index_term_list))
- Index_clause.setName('index_clause')
- Index_list = Index_clause('index')
- Index_list.setName('index_list')
- Index_block = Group('indexing' + Group(OneOrMore(Index_list + Suppress(';'))))('indexes')
-
-
class CommentParserTest(ParseTestCase):
def runTest(self):