summaryrefslogtreecommitdiff
path: root/unitTests.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2019-06-29 01:23:01 -0500
committerPaul McGuire <ptmcg@austin.rr.com>2019-06-29 01:23:01 -0500
commit46c9b81857f56a245786dcdef3699e85f5fdd71a (patch)
tree843e7800662ff9e3c79bbb7526cd6a0d493c854c /unitTests.py
parent56eea1d34c2de9d505c945f58bb75e88bb5676c6 (diff)
downloadpyparsing-git-46c9b81857f56a245786dcdef3699e85f5fdd71a.tar.gz
Add support for expr.setParseAction(None) to clear all parse actions
Diffstat (limited to 'unitTests.py')
-rw-r--r--unitTests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/unitTests.py b/unitTests.py
index e14016a..4c6c9ab 100644
--- a/unitTests.py
+++ b/unitTests.py
@@ -3009,6 +3009,20 @@ class TrimArityExceptionMaskingTest2(ParseTestCase):
K()
+
+class ClearParseActionsTest(ParseTestCase):
+ def runTest(self):
+ import pyparsing as pp
+ ppc = pp.pyparsing_common
+
+ realnum = ppc.real()
+ self.assertEqual(realnum.parseString("3.14159")[0], 3.14159, "failed basic real number parsing")
+
+ # clear parse action that converts to float
+ realnum.setParseAction(None)
+ self.assertEqual(realnum.parseString("3.14159")[0], "3.14159", "failed clearing parse action")
+
+
class OneOrMoreStopTest(ParseTestCase):
def runTest(self):
from pyparsing import (Word, OneOrMore, alphas, Keyword, CaselessKeyword,