summaryrefslogtreecommitdiff
path: root/unitTests.py
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2018-10-12 23:42:09 -0500
committerptmcg <ptmcg@austin.rr.com>2018-10-12 23:42:09 -0500
commit2fe1bb0be12e9c603bc82d3990b9305c248d99e1 (patch)
tree32dba266a616f312a357956d3975fe28bc28b9d6 /unitTests.py
parentdc074e25459062578e9104dda3e86b662715f966 (diff)
downloadpyparsing-git-2fe1bb0be12e9c603bc82d3990b9305c248d99e1.tar.gz
Fix extra nesting level in ParseResults when defining results name in another non-Group named expression
Diffstat (limited to 'unitTests.py')
-rw-r--r--unitTests.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/unitTests.py b/unitTests.py
index 9ebf02b..9a78bf5 100644
--- a/unitTests.py
+++ b/unitTests.py
@@ -3572,6 +3572,21 @@ class ParseActionNestingTest(ParseTestCase):
print("result1.dump():\n" + result1.dump() + "\n")
assert before_pa_dict == after_pa_dict, "noop parse action changed ParseResults structure"
+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")
+ + pp.Literal("]")("END_LIST"))("LIST")
+
+ test_string = "[ 1,2,3,4,5,6 ]"
+ list_num.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):