diff options
| author | ptmcg <ptmcg@austin.rr.com> | 2018-12-28 14:55:39 -0600 |
|---|---|---|
| committer | ptmcg <ptmcg@austin.rr.com> | 2018-12-28 14:55:39 -0600 |
| commit | c50c84bac138f176259cf745e628000fd8539330 (patch) | |
| tree | 5151f3d22bee45609a9824d91c339613ae1cd8f8 /unitTests.py | |
| parent | 45b78401e8c224619e1b18b9cf43fc02b196676e (diff) | |
| download | pyparsing-git-c50c84bac138f176259cf745e628000fd8539330.tar.gz | |
Fix matching of dictOf with empty contents (Issue #53)
Diffstat (limited to 'unitTests.py')
| -rw-r--r-- | unitTests.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/unitTests.py b/unitTests.py index cd219bf..9d2731a 100644 --- a/unitTests.py +++ b/unitTests.py @@ -3851,6 +3851,25 @@ class ParseResultsWithNameOr(ParseTestCase): self.assertEqual(list(expr.parseString('not the bird')['rexp']), 'not the bird'.split())
self.assertEqual(list(expr.parseString('the bird')['rexp']), 'the bird'.split())
+class EmptyDictDoesNotRaiseException(ParseTestCase):
+ def runTest(self):
+ import pyparsing as pp
+
+ key = pp.Word(pp.alphas)
+ value = pp.Word(pp.nums)
+ EQ = pp.Suppress('=')
+ key_value_dict = pp.dictOf(key, EQ + value)
+ try:
+ print(key_value_dict.parseString("""\
+ a = 10
+ b = 20
+ """).dump())
+ print(key_value_dict.parseString("").dump())
+ except pp.ParseException:
+ pass
+ else:
+ self.assertTrue(False, "failed to raise exception when matching empty string")
+
class MiscellaneousParserTests(ParseTestCase):
def runTest(self):
|
