summaryrefslogtreecommitdiff
path: root/pyparsing/core.py
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2021-11-05 05:17:02 -0500
committerptmcg <ptmcg@austin.rr.com>2021-11-05 05:17:02 -0500
commitac11feb2d286afe0c8fa2bc6b4afe707d0a0e00c (patch)
tree3198da8279f3071c44cca06ed392120cfc2026ea /pyparsing/core.py
parent08bdeebe71d019e8be3e5a8b3d348ec44daf9e17 (diff)
downloadpyparsing-git-ac11feb2d286afe0c8fa2bc6b4afe707d0a0e00c.tar.gz
Added with_line_numbers to run_test(), and made line/col numbering off by default
Diffstat (limited to 'pyparsing/core.py')
-rw-r--r--pyparsing/core.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py
index 6fb8f92..56f64cc 100644
--- a/pyparsing/core.py
+++ b/pyparsing/core.py
@@ -1910,6 +1910,7 @@ class ParserElement(ABC):
failure_tests: bool = False,
post_parse: Callable[[str, ParseResults], str] = None,
file: OptionalType[TextIO] = None,
+ with_line_numbers: bool = False,
*,
parseAll: bool = True,
fullDump: bool = True,
@@ -1935,6 +1936,7 @@ class ParserElement(ABC):
`fn(test_string, parse_results)` and returns a string to be added to the test output
- ``file`` - (default= ``None``) optional file-like object to which test output will be written;
if None, will default to ``sys.stdout``
+ - ``with_line_numbers`` - default= ``False``) show test strings with line and column numbers
Returns: a (success, results) tuple, where success indicates that all tests succeeded
(or failed if ``failure_tests`` is True), and the results contain a list of lines of each
@@ -2039,7 +2041,7 @@ class ParserElement(ABC):
continue
out = [
"\n" + "\n".join(comments) if comments else "",
- pyparsing_test.with_line_numbers(t),
+ pyparsing_test.with_line_numbers(t) if with_line_numbers else t,
]
comments = []
try:
@@ -2077,7 +2079,7 @@ class ParserElement(ABC):
)
else:
out.append(result.dump(full=fullDump))
- out.append("")
+ out.append("")
if printResults:
print_("\n".join(out))