diff options
author | ptmcg <ptmcg@austin.rr.com> | 2018-11-13 18:24:44 -0600 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2018-11-13 18:24:44 -0600 |
commit | 905b01bece3a17e952cb11eaa8c9d2d272b27569 (patch) | |
tree | 651bf4f092075ab87a6979a350f493e8a6834b76 /unitTests.py | |
parent | 3189e42fcec49b0cd2d7ba44ff7d4b6e38032e8e (diff) | |
download | pyparsing-git-905b01bece3a17e952cb11eaa8c9d2d272b27569.tar.gz |
Add unit test for named ParseResults combined with Dict-created named results in the same Group; removed reference to UnicodeTests, which subsetted the tests that were actually being run
Diffstat (limited to 'unitTests.py')
-rw-r--r-- | unitTests.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/unitTests.py b/unitTests.py index e4f2c63..5cb293d 100644 --- a/unitTests.py +++ b/unitTests.py @@ -3573,7 +3573,7 @@ class ParseActionNestingTest(ParseTestCase): class ParseResultsNameBelowUngroupedNameTest(ParseTestCase):
def runTest(self):
import pyparsing as pp
-
+
rule_num = pp.Regex("[0-9]+")("LIT_NUM*")
list_num = pp.Group(pp.Literal("[")("START_LIST")
+ pp.delimitedList(rule_num)("LIST_VALUES")
@@ -3585,7 +3585,25 @@ class ParseResultsNameBelowUngroupedNameTest(ParseTestCase): U = list_num.parseString(test_string)
assert "LIT_NUM" not in U.LIST.LIST_VALUES, "results name retained as sub in ungrouped named result"
-
+class ParseResultsNamesInGroupWithDictTest(ParseTestCase):
+ def runTest(self):
+ import pyparsing as pp
+
+ key = pp.pyparsing_common.identifier()
+ value = pp.pyparsing_common.integer()
+ lat = pp.pyparsing_common.real()
+ long = pp.pyparsing_common.real()
+ EQ = pp.Suppress('=')
+
+ data = lat("lat") + long("long") + pp.Dict(pp.OneOrMore(pp.Group(key + EQ + value)))
+ site = pp.QuotedString('"')("name") + pp.Group(data)("data")
+
+ test_string = '"Golden Gate Bridge" 37.819722 -122.478611 height=746 span=4200'
+ site.runTests(test_string)
+
+ # U = list_num.parseString(test_string)
+ # assert "LIT_NUM" not in U.LIST.LIST_VALUES, "results name retained as sub in ungrouped named result"
+
class FollowedByTest(ParseTestCase):
def runTest(self):
expr = pp.Word(pp.alphas)("item") + pp.FollowedBy(pp.pyparsing_common.integer("qty"))
@@ -3932,7 +3950,6 @@ if __name__ == '__main__': # run specific tests by including them in this list, otherwise
# all tests will be run
testclasses = [
- UnicodeTests
]
if not testclasses:
|