summaryrefslogtreecommitdiff
path: root/tests/test_files.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-10-02 21:39:36 -0400
committerNed Batchelder <ned@nedbatchelder.com>2022-10-15 13:58:50 -0400
commit7836b4faa320cccdeb25966dd8fefcf89107c564 (patch)
tree2e6a43d2c59173696b856f1a588c872d8601fa42 /tests/test_files.py
parent60fa1306d2b02aa718a21c8e9da10fc063063fe7 (diff)
downloadpython-coveragepy-git-7836b4faa320cccdeb25966dd8fefcf89107c564.tar.gz
fix: */foo matches "foo/x.py", to help with combining relative file names. #991
Diffstat (limited to 'tests/test_files.py')
-rw-r--r--tests/test_files.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_files.py b/tests/test_files.py
index 58084f7c..3f3caae6 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -144,6 +144,12 @@ def test_flat_rootname(original, flat):
["abc/foo/hi.py", "ABC/foo/bar/hi.py", r"ABC\foo/bar/hi.py"],
["abcd/foo.py", "xabc/hi.py"],
),
+ (
+ ["*/foo"], False, True,
+ ["abc/foo/hi.py", "foo/hi.py"],
+ ["abc/xfoo/hi.py"],
+ ),
+
])
def test_fnmatches_to_regex(patterns, case_insensitive, partial, matches, nomatches):
regex = fnmatches_to_regex(patterns, case_insensitive=case_insensitive, partial=partial)
@@ -386,6 +392,30 @@ class PathAliasesTest(CoverageTest):
"project\\module\\tests\\file.py",
)
+ @pytest.mark.parametrize("paths", lin_win_paths)
+ def test_relative_windows_on_linux(self, paths):
+ # https://github.com/nedbat/coveragepy/issues/991
+ aliases = PathAliases(relative=True)
+ for path in paths:
+ aliases.add(path, "project/module")
+ self.assert_mapped(
+ aliases,
+ r"project\module\tests\file.py",
+ r"project/module/tests/file.py",
+ )
+
+ @pytest.mark.parametrize("paths", lin_win_paths)
+ def test_relative_linux_on_windows(self, paths):
+ # https://github.com/nedbat/coveragepy/issues/991
+ aliases = PathAliases(relative=True)
+ for path in paths:
+ aliases.add(path, r"project\module")
+ self.assert_mapped(
+ aliases,
+ r"project/module/tests/file.py",
+ r"project\module\tests\file.py",
+ )
+
def test_multiple_wildcard(self, rel_yn):
aliases = PathAliases(relative=rel_yn)
aliases.add('/home/jenkins/*/a/*/b/*/django', './django')