diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2014-04-09 13:56:20 +0000 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2014-04-09 13:56:20 +0000 |
commit | 66efeb5df07c90bbf4905f1cb4d36889aeca42a9 (patch) | |
tree | b7b2fe775a59c7293f9cfa662eb5e0c915c1f98a /src/unitTests.py | |
parent | 85c8ae8ff33ff008b844835a5520e19ba073d909 (diff) | |
download | pyparsing-git-66efeb5df07c90bbf4905f1cb4d36889aeca42a9.tar.gz |
Fixed markInputline bug; reverted some <<= to << changes to avoid local/nonlocal reference problems
Diffstat (limited to 'src/unitTests.py')
-rw-r--r-- | src/unitTests.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/unitTests.py b/src/unitTests.py index 468952f..915a788 100644 --- a/src/unitTests.py +++ b/src/unitTests.py @@ -2153,6 +2153,24 @@ class SumParseResultsTest(ParseTestCase): assert expected == result, \
"Failed to parse '%s' correctly, \nexpected '%s', got '%s'" % (test,expected,result)
+class MarkInputLineTest(ParseTestCase):
+ def runTest(self):
+
+ samplestr1 = "DOB 100-10-2010;more garbage\nID PARI12345678;more garbage"
+
+ from pyparsing import Regex, Word, alphanums, restOfLine
+ dob_ref = "DOB" + Regex(r"\d{2}-\d{2}-\d{4}")("dob")
+
+ try:
+ res = dob_ref.parseString(samplestr1)
+ except ParseException as pe:
+ outstr = pe.markInputline()
+ print_(outstr)
+ assert outstr == "DOB >!<100-10-2010;more garbage", "did not properly create marked input line"
+ else:
+ assert False, "test construction failed - should have raised an exception"
+
+
class MiscellaneousParserTests(ParseTestCase):
def runTest(self):
import pyparsing
@@ -2358,6 +2376,7 @@ def makeTestSuite(): suite.addTest( OptionalEachTest() )
suite.addTest( SumParseResultsTest() )
suite.addTest( WordExcludeTest() )
+ suite.addTest( MarkInputLineTest() )
suite.addTest( MiscellaneousParserTests() )
if TEST_USING_PACKRAT:
# retest using packrat parsing (disable those tests that aren't compatible)
@@ -2377,7 +2396,8 @@ def makeTestSuiteTemp(): suite = TestSuite()
suite.addTest( PyparsingTestInit() )
#~ suite.addTest( OptionalEachTest() )
- suite.addTest( RepeaterTest() )
+ #~ suite.addTest( RepeaterTest() )
+ suite.addTest( MarkInputLineTest() )
return suite
|