diff options
author | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2016-09-11 16:31:34 +0000 |
---|---|---|
committer | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2016-09-11 16:31:34 +0000 |
commit | d43042b33d0b42b7b4dfce42fe45a2947212f395 (patch) | |
tree | 43eff6aaad40392c5a3d25e85a3efdd835778da6 | |
parent | 18f9cb27dd1694c0747c0add99e38622dc8b72c8 (diff) | |
download | pyparsing-d43042b33d0b42b7b4dfce42fe45a2947212f395.tar.gz |
Added support for multiline test strings in runTests
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@437 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-rw-r--r-- | src/CHANGES | 3 | ||||
-rw-r--r-- | src/pyparsing.py | 10 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/CHANGES b/src/CHANGES index 4158bb7..d5f59a2 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -4,8 +4,7 @@ Change Log Version 2.1.10 -
-------------------------------
-- Added support for regex module (alternative to Python's built-in
- re module).
+- Added support for multiline test strings in runTests.
Version 2.1.9 - September, 2016
diff --git a/src/pyparsing.py b/src/pyparsing.py index 70fe4eb..5517d02 100644 --- a/src/pyparsing.py +++ b/src/pyparsing.py @@ -61,7 +61,7 @@ The pyparsing module handles some of the problems that are typically vexing when """
__version__ = "2.1.10"
-__versionTime__ = "11 Sep 2016 01:15 UTC"
+__versionTime__ = "11 Sep 2016 16:20 UTC"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -2267,6 +2267,13 @@ class ParserElement(object): FAIL: Expected end of text (at char 4), (line:1, col:5)
Success
+
+ Each test string must be on a single line. If you want to test a string that spans multiple
+ lines, create a test like this::
+
+ expr.runTest(r"this is a test\n of strings that spans \n 3 lines")
+
+ (Note that this is a raw string literal, you must include the leading 'r'.)
"""
if isinstance(tests, basestring):
tests = list(map(str.strip, tests.rstrip().splitlines()))
@@ -2284,6 +2291,7 @@ class ParserElement(object): out = ['\n'.join(comments), t]
comments = []
try:
+ t = t.replace(r'\n','\n')
result = self.parseString(t, parseAll=parseAll)
out.append(result.dump(full=fullDump))
success = success and not failureTests
|