From ec6205a8de972af6a09453235d02a7ebea6aea8e Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 23 Oct 2022 14:03:17 -0400 Subject: fix: use glob matching instead of fnmatch. #1407 I didn't understand that fnmatch considers the entire string to be a filename, even if it has slashes in it. This led to incorrect matching. Now we use our own implementation of glob matching to get the correct behavior. --- coverage/inorout.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'coverage/inorout.py') diff --git a/coverage/inorout.py b/coverage/inorout.py index ec89d1b4..2e534c85 100644 --- a/coverage/inorout.py +++ b/coverage/inorout.py @@ -16,7 +16,7 @@ import traceback from coverage import env from coverage.disposition import FileDisposition, disposition_init from coverage.exceptions import CoverageException, PluginError -from coverage.files import TreeMatcher, FnmatchMatcher, ModuleMatcher +from coverage.files import TreeMatcher, GlobMatcher, ModuleMatcher from coverage.files import prep_patterns, find_python_files, canonical_filename from coverage.misc import sys_modules_saved from coverage.python import source_for_file, source_for_morf @@ -260,10 +260,10 @@ class InOrOut: self.pylib_match = TreeMatcher(self.pylib_paths, "pylib") debug(f"Python stdlib matching: {self.pylib_match!r}") if self.include: - self.include_match = FnmatchMatcher(self.include, "include") + self.include_match = GlobMatcher(self.include, "include") debug(f"Include matching: {self.include_match!r}") if self.omit: - self.omit_match = FnmatchMatcher(self.omit, "omit") + self.omit_match = GlobMatcher(self.omit, "omit") debug(f"Omit matching: {self.omit_match!r}") self.cover_match = TreeMatcher(self.cover_paths, "coverage") -- cgit v1.2.1