summaryrefslogtreecommitdiff
path: root/lab
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-01-07 19:46:57 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-01-07 19:46:57 -0500
commitd93ddb9524a3e3535541812bbeade8e8ff822409 (patch)
tree6256b78b56e06ff815bf781593749ae96d15a9bf /lab
parent2e48dedf1ea439988fba0c9693cea7a818ab3213 (diff)
downloadpython-coveragepy-git-d93ddb9524a3e3535541812bbeade8e8ff822409.tar.gz
When extracting snippets, also need to undo backslashing
--HG-- branch : ast-branch
Diffstat (limited to 'lab')
-rw-r--r--lab/parser.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/lab/parser.py b/lab/parser.py
index 08b50921..5e5b4b36 100644
--- a/lab/parser.py
+++ b/lab/parser.py
@@ -77,7 +77,8 @@ class ParserMain(object):
def one_file(self, options, filename):
"""Process just one file."""
# `filename` can have a line number suffix. In that case, extract those
- # lines, dedent them, and use that.
+ # lines, dedent them, and use that. This is for trying test cases
+ # embedded in the test files.
match = re.search(r"^(.*):(\d+)-(\d+)$", filename)
if match:
filename, start, end = match.groups()
@@ -89,7 +90,7 @@ class ParserMain(object):
text = get_python_source(filename)
if start is not None:
lines = text.splitlines(True)
- text = textwrap.dedent("".join(lines[start-1:end]))
+ text = textwrap.dedent("".join(lines[start-1:end]).replace("\\\\", "\\"))
bp = ByteParser(text, filename=filename)
except Exception as err:
print("%s" % (err,))