diff options
-rw-r--r-- | coverage/plugin.py | 5 | ||||
-rw-r--r-- | tests/test_xml.py | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/coverage/plugin.py b/coverage/plugin.py index bd997ac3..20d7ee8f 100644 --- a/coverage/plugin.py +++ b/coverage/plugin.py @@ -1,5 +1,6 @@ """Plugin interfaces for coverage.py""" +import os import re from coverage.misc import _needs_to_implement @@ -240,5 +241,5 @@ class FileReporter(object): For example, the file a/b/c.py will return 'a_b_c_py' """ - # TODO: a better generic implementation? - return re.sub(r"[\/.:]", "_", self.name) + name = os.path.splitdrive(self.name)[1] + return re.sub(r"[\\/.:]", "_", name) diff --git a/tests/test_xml.py b/tests/test_xml.py index d7611ebf..b9b36efb 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -238,8 +238,14 @@ def re_line(text, pat): def clean(text, scrub=None): - """Remove any text matching `scrub`, and all leading whitespace.""" + """Clean text to prepare it for comparison. + + Remove text matching `scrub`, and leading whitespace. Convert backslashes + to forward slashes. + + """ if scrub: text = re.sub(scrub, "", text) text = re.sub(r"(?m)^\s+", "", text) + text = re.sub(r"\\", "/", text) return text |