diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2016-01-07 19:46:57 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2016-01-07 19:46:57 -0500 |
commit | 7650c3d69c945fc204b60267bf88bcd77b52f13b (patch) | |
tree | 356f20605a0ac0836eca10f0477deb1b8a45f38d /lab/parser.py | |
parent | 858c44bb1007511a69e0ed9ea60ccd3f9fe3eb56 (diff) | |
download | python-coveragepy-7650c3d69c945fc204b60267bf88bcd77b52f13b.tar.gz |
When extracting snippets, also need to undo backslashing
Diffstat (limited to 'lab/parser.py')
-rw-r--r-- | lab/parser.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lab/parser.py b/lab/parser.py index 08b5092..5e5b4b3 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,)) |