diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2018-02-10 10:15:04 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2018-02-10 10:15:04 -0500 |
commit | ccb6896d0717c83147a43f4e25f7f76c9a8807e4 (patch) | |
tree | 31a2590b5e1981d40d21a1132f6cd5e3f9a46b34 | |
parent | cbfefaeed86e276677d4c0aa56c5897eb67dcf10 (diff) | |
download | python-coveragepy-ccb6896d0717c83147a43f4e25f7f76c9a8807e4.tar.gz |
Oops, omitting inside a source package didn't work. Now it does. #638
-rw-r--r-- | CHANGES.rst | 6 | ||||
-rw-r--r-- | coverage/control.py | 4 | ||||
-rw-r--r-- | tests/test_api.py | 7 |
3 files changed, 14 insertions, 3 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 3779a00..ad401eb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -19,10 +19,16 @@ Change history for Coverage.py Unreleased ---------- +- Now that 4.5 properly separated the ``[run] omit`` and ``[report] omit`` + settings, and old bug has become apparent. If you specified a package name + for ``[run] source``, then omit patterns weren't matched inside that package. + This bug (`issue 638`_) is now fixed. + - On Python 3.7, reporting about a decorated function with no body other than a docstring would crash coverage.py with an IndexError (`issue 640`_). This is now fixed. +.. _issue 638: https://bitbucket.org/ned/coveragepy/issues/638/run-omit-is-ignored-since-45 .. _issue 640: https://bitbucket.org/ned/coveragepy/issues/640/indexerror-reporting-on-an-empty-decorated diff --git a/coverage/control.py b/coverage/control.py index f1db1ef..cfe9409 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -559,9 +559,7 @@ class Coverage(object): if self.source_pkgs_match.match(modulename): if modulename in self.source_pkgs_unmatched: self.source_pkgs_unmatched.remove(modulename) - return None # There's no reason to skip this file. - - if not self.source_match.match(filename): + elif not self.source_match.match(filename): return "falls outside the --source trees" elif self.include_match: if not self.include_match.match(filename): diff --git a/tests/test_api.py b/tests/test_api.py index b5fcd53..b461c50 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -615,6 +615,13 @@ class SourceOmitIncludeTest(OmitIncludeTestsMixin, CoverageTest): self.filenames_not_in(lines, "p1b") self.assertEqual(lines['p1c'], 0) + def test_source_package_as_package_part_omitted(self): + # https://bitbucket.org/ned/coveragepy/issues/638/run-omit-is-ignored-since-45 + lines = self.coverage_usepkgs(source=["pkg1"], omit=["*/p1b.py"]) + self.filenames_in(lines, "p1a") + self.filenames_not_in(lines, "p1b") + self.assertEqual(lines['p1c'], 0) + class ReportIncludeOmitTest(OmitIncludeTestsMixin, CoverageTest): """Tests of the report include/omit functionality.""" |