diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2018-12-21 00:19:24 -0600 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2018-12-21 00:19:24 -0600 |
commit | e1ee379b3a52632d4fa419d199780349e831470b (patch) | |
tree | af2aa3d6f93257c00e84b2d9cca138c499e37599 /unitTests.py | |
parent | 569966d06a0c0ea25843d84c7559f9e797346acc (diff) | |
download | pyparsing-git-e1ee379b3a52632d4fa419d199780349e831470b.tar.gz |
Add support for optional postParse argument to ParserElement.runTests
Diffstat (limited to 'unitTests.py')
-rw-r--r-- | unitTests.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/unitTests.py b/unitTests.py index adf433f..c831fc4 100644 --- a/unitTests.py +++ b/unitTests.py @@ -103,7 +103,6 @@ class ParseTestCase(TestCase): print_(buffered_stdout.getvalue())
raise
-
def runTest(self):
pass
@@ -3058,6 +3057,23 @@ class RunTestsTest(ParseTestCase): success = indices.runTests(tests, printResults=False, failureTests=True)[0]
assert success, "failed to raise exception on improper range test"
+class RunTestsPostParseTest(ParseTestCase):
+ def runTest(self):
+ import pyparsing as pp
+
+ integer = pp.pyparsing_common.integer
+ fraction = integer('numerator') + '/' + integer('denominator')
+
+ def eval_fraction(test, result):
+ return "eval: {}".format(result.numerator / result.denominator)
+
+ success = fraction.runTests("""\
+ 1/2
+ 1/0
+ """, postParse=eval_fraction)
+
+ self.assertTrue(success, "failed to parse fractions in RunTestsPostParse")
+
class CommonExpressionsTest(ParseTestCase):
def runTest(self):
from pyparsing import pyparsing_common
|