diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-04-11 08:58:56 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-04-11 09:13:36 -0400 |
commit | 16f54a935a1c41618e098bebdbcb77b638f40c6c (patch) | |
tree | d76db410df6de56e14f4db95354b1ff52cdcc7c3 /coverage | |
parent | 0285af966a3942d8bd63489bd285328e96221126 (diff) | |
download | python-coveragepy-git-16f54a935a1c41618e098bebdbcb77b638f40c6c.tar.gz |
debug: label each matcher with its role
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/files.py | 15 | ||||
-rw-r--r-- | coverage/inorout.py | 14 | ||||
-rw-r--r-- | coverage/report.py | 4 |
3 files changed, 18 insertions, 15 deletions
diff --git a/coverage/files.py b/coverage/files.py index 1cf4b18e..d6826830 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -215,12 +215,13 @@ class TreeMatcher(object): somewhere in a subtree rooted at one of the directories. """ - def __init__(self, paths): + def __init__(self, paths, name): self.original_paths = list(paths) self.paths = list(map(os.path.normcase, paths)) + self.name = name def __repr__(self): - return "<TreeMatcher %r>" % self.paths + return "<TreeMatcher {!r} {!r}>".format(self.name, self.original_paths) def info(self): """A list of strings for displaying when dumping state.""" @@ -242,11 +243,12 @@ class TreeMatcher(object): class ModuleMatcher(object): """A matcher for modules in a tree.""" - def __init__(self, module_names): + def __init__(self, module_names, name): self.modules = list(module_names) + self.name = name def __repr__(self): - return "<ModuleMatcher %r>" % (self.modules) + return "<ModuleMatcher {!r} {!r}>".format(self.name, self.modules) def info(self): """A list of strings for displaying when dumping state.""" @@ -270,12 +272,13 @@ class ModuleMatcher(object): class FnmatchMatcher(object): """A matcher for files by file name pattern.""" - def __init__(self, pats): + def __init__(self, pats, name): self.pats = list(pats) self.re = fnmatches_to_regex(self.pats, case_insensitive=env.WINDOWS) + self.name = name def __repr__(self): - return "<FnmatchMatcher %r>" % self.pats + return "<FnmatchMatcher {!r} {!r}>".format(self.name, self.pats) def info(self): """A list of strings for displaying when dumping state.""" diff --git a/coverage/inorout.py b/coverage/inorout.py index a773af76..9861dac6 100644 --- a/coverage/inorout.py +++ b/coverage/inorout.py @@ -258,27 +258,27 @@ class InOrOut(object): if self.source or self.source_pkgs: against = [] if self.source: - self.source_match = TreeMatcher(self.source) + self.source_match = TreeMatcher(self.source, "source") against.append("trees {!r}".format(self.source_match)) if self.source_pkgs: - self.source_pkgs_match = ModuleMatcher(self.source_pkgs) + self.source_pkgs_match = ModuleMatcher(self.source_pkgs, "source_pkgs") against.append("modules {!r}".format(self.source_pkgs_match)) debug("Source matching against " + " and ".join(against)) else: if self.cover_paths: - self.cover_match = TreeMatcher(self.cover_paths) + self.cover_match = TreeMatcher(self.cover_paths, "coverage") debug("Coverage code matching: {!r}".format(self.cover_match)) if self.pylib_paths: - self.pylib_match = TreeMatcher(self.pylib_paths) + self.pylib_match = TreeMatcher(self.pylib_paths, "pylib") debug("Python stdlib matching: {!r}".format(self.pylib_match)) if self.include: - self.include_match = FnmatchMatcher(self.include) + self.include_match = FnmatchMatcher(self.include, "include") debug("Include matching: {!r}".format(self.include_match)) if self.omit: - self.omit_match = FnmatchMatcher(self.omit) + self.omit_match = FnmatchMatcher(self.omit, "omit") debug("Omit matching: {!r}".format(self.omit_match)) if self.third_paths: - self.third_match = TreeMatcher(self.third_paths) + self.third_match = TreeMatcher(self.third_paths, "third") debug("Third-party lib matching: {!r}".format(self.third_match)) # Check if the source we want to measure has been installed as a diff --git a/coverage/report.py b/coverage/report.py index 4ed0c7ef..9dfc8f5e 100644 --- a/coverage/report.py +++ b/coverage/report.py @@ -57,11 +57,11 @@ def get_analysis_to_report(coverage, morfs): config = coverage.config if config.report_include: - matcher = FnmatchMatcher(prep_patterns(config.report_include)) + matcher = FnmatchMatcher(prep_patterns(config.report_include), "report_include") file_reporters = [fr for fr in file_reporters if matcher.match(fr.filename)] if config.report_omit: - matcher = FnmatchMatcher(prep_patterns(config.report_omit)) + matcher = FnmatchMatcher(prep_patterns(config.report_omit), "report_omit") file_reporters = [fr for fr in file_reporters if not matcher.match(fr.filename)] if not file_reporters: |