summaryrefslogtreecommitdiff
path: root/tests/test_files.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-09-16 17:48:02 -0400
committerNed Batchelder <ned@nedbatchelder.com>2022-09-16 18:17:55 -0400
commit7b690aa976a6bb30261d68344104f817a812a677 (patch)
treee81568929e612ee14674d7a71abf3370c6d346b1 /tests/test_files.py
parent30d37e59e50b75c057a09fddf5b92869c0858949 (diff)
downloadpython-coveragepy-git-7b690aa976a6bb30261d68344104f817a812a677.tar.gz
feat: --debug=pathmap will show details of re-mapping due to [paths] setting.
Diffstat (limited to 'tests/test_files.py')
-rw-r--r--tests/test_files.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/test_files.py b/tests/test_files.py
index 9f7f6278..b1e85610 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -289,11 +289,37 @@ class PathAliasesTest(CoverageTest):
self.assert_unchanged(aliases, '/home/foo/srcetc')
def test_multiple_patterns(self, rel_yn):
- aliases = PathAliases(relative=rel_yn)
+ # also test the debugfn...
+ msgs = []
+ aliases = PathAliases(debugfn=msgs.append, relative=rel_yn)
aliases.add('/home/*/src', './mysrc')
aliases.add('/lib/*/libsrc', './mylib')
self.assert_mapped(aliases, '/home/foo/src/a.py', './mysrc/a.py', relative=rel_yn)
self.assert_mapped(aliases, '/lib/foo/libsrc/a.py', './mylib/a.py', relative=rel_yn)
+ if rel_yn:
+ assert msgs == [
+ "Aliases (relative=True):",
+ " Rule: '/home/*/src' -> './mysrc/' using regex " +
+ "'(?:(?s:[\\\\\\\\/]home[\\\\\\\\/].*[\\\\\\\\/]src[\\\\\\\\/]))'",
+ " Rule: '/lib/*/libsrc' -> './mylib/' using regex " +
+ "'(?:(?s:[\\\\\\\\/]lib[\\\\\\\\/].*[\\\\\\\\/]libsrc[\\\\\\\\/]))'",
+ "Matched path '/home/foo/src/a.py' to rule '/home/*/src' -> './mysrc/', " +
+ "producing './mysrc/a.py'",
+ "Matched path '/lib/foo/libsrc/a.py' to rule '/lib/*/libsrc' -> './mylib/', " +
+ "producing './mylib/a.py'",
+ ]
+ else:
+ assert msgs == [
+ "Aliases (relative=False):",
+ " Rule: '/home/*/src' -> './mysrc/' using regex " +
+ "'(?:(?s:[\\\\\\\\/]home[\\\\\\\\/].*[\\\\\\\\/]src[\\\\\\\\/]))'",
+ " Rule: '/lib/*/libsrc' -> './mylib/' using regex " +
+ "'(?:(?s:[\\\\\\\\/]lib[\\\\\\\\/].*[\\\\\\\\/]libsrc[\\\\\\\\/]))'",
+ "Matched path '/home/foo/src/a.py' to rule '/home/*/src' -> './mysrc/', " +
+ f"producing {files.canonical_filename('./mysrc/a.py')!r}",
+ "Matched path '/lib/foo/libsrc/a.py' to rule '/lib/*/libsrc' -> './mylib/', " +
+ f"producing {files.canonical_filename('./mylib/a.py')!r}",
+ ]
@pytest.mark.parametrize("badpat", [
"/ned/home/*",