From 7836b4faa320cccdeb25966dd8fefcf89107c564 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 2 Oct 2022 21:39:36 -0400 Subject: fix: */foo matches "foo/x.py", to help with combining relative file names. #991 --- coverage/files.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'coverage/files.py') 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) -- cgit v1.2.1