diff options
| author | ptmcg <ptmcg@austin.rr.com> | 2020-04-10 16:52:46 -0500 |
|---|---|---|
| committer | ptmcg <ptmcg@austin.rr.com> | 2020-04-10 16:52:46 -0500 |
| commit | 486b1fd2ef7e98966665f915bc59856996ffb5b0 (patch) | |
| tree | 1ac012ef3e6fc535a69304d936facbbdb7baad5e /tests | |
| parent | 72f2c5a67b4a26f584104b9ff63e1f272f54c5df (diff) | |
| download | pyparsing-git-486b1fd2ef7e98966665f915bc59856996ffb5b0.tar.gz | |
Fixed bug in ParseResults repr() which showed all matching entries for a results name, even if listAllMatches was set to False (Issue #205)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_unit.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_unit.py b/tests/test_unit.py index de06ddf..9f27375 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -7073,6 +7073,33 @@ class Test2_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase): "multiplied(3) failure with setResultsName", ) + def testParseResultsReprWithResultsNames(self): + word = pp.Word(pp.printables)("word") + res = word[...].parseString("test blub") + + print(repr(res)) + print(res["word"]) + print(res.asDict()) + + self.assertEqual( + "(['test', 'blub'], {'word': 'blub'})", + repr(res), + "incorrect repr for ParseResults with listAllMatches=False", + ) + + word = pp.Word(pp.printables)("word*") + res = word[...].parseString("test blub") + + print(repr(res)) + print(res["word"]) + print(res.asDict()) + + self.assertEqual( + "(['test', 'blub'], {'word': ['test', 'blub']})", + repr(res), + "incorrect repr for ParseResults with listAllMatches=True", + ) + def testWarnUsingLshiftForward(self): import warnings |
