diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2022-10-02 21:39:36 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2022-10-15 13:58:50 -0400 |
commit | 7836b4faa320cccdeb25966dd8fefcf89107c564 (patch) | |
tree | 2e6a43d2c59173696b856f1a588c872d8601fa42 /coverage/files.py | |
parent | 60fa1306d2b02aa718a21c8e9da10fc063063fe7 (diff) | |
download | python-coveragepy-git-7836b4faa320cccdeb25966dd8fefcf89107c564.tar.gz |
fix: */foo matches "foo/x.py", to help with combining relative file names. #991
Diffstat (limited to 'coverage/files.py')
-rw-r--r-- | coverage/files.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/coverage/files.py b/coverage/files.py index 4475f2f1..87a18bc2 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -296,6 +296,8 @@ def fnmatches_to_regex(patterns, case_insensitive=False, partial=False): """ regexes = (fnmatch.translate(pattern) for pattern in patterns) + # */ at the start should also match nothing. + regexes = (re.sub(r"^\(\?s:\.\*(\\\\|/)", r"(?s:^(.*\1)?", regex) for regex in regexes) # Be agnostic: / can mean backslash or slash. regexes = (re.sub(r"/", r"[\\\\/]", regex) for regex in regexes) |