diff options
-rw-r--r-- | CHANGES.txt | 8 | ||||
-rw-r--r-- | coverage/control.py | 6 | ||||
-rw-r--r-- | tests/test_api.py | 12 |
3 files changed, 24 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 0f49740..48876c1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,7 +8,11 @@ Change history for Coverage.py - Improved the branch coverage mechanism, fixing `issue 175`_. - Running code with ``coverage run -m`` now behaves more like Python does, - setting sys.path properly, which fixes `issue 207`_ and `issue 242`. + setting sys.path properly, which fixes `issue 207`_ and `issue 242`_. + +- Omitting files within a tree specified with the ``source`` option would + cause them to be incorrectly marked as unexecuted, as described in + `issue 218`_. This is now fixed. - When running a threaded program under the Python tracer, coverage would issue a spurious warning about the trace function changing: "Trace function @@ -18,6 +22,8 @@ Change history for Coverage.py .. _issue 175: https://bitbucket.org/ned/coveragepy/issue/175/branch-coverage-gets-confused-in-certain .. _issue 207: https://bitbucket.org/ned/coveragepy/issue/207/run-m-cannot-find-module-or-package-in .. _issue 242: https://bitbucket.org/ned/coveragepy/issue/242/running-a-two-level-package-doesnt-work +.. _issue 218: https://bitbucket.org/ned/coveragepy/issue/218/run-command-does-not-respect-the-omit-flag + Version 3.6 --- 5 January 2013 ------------------------------ diff --git a/coverage/control.py b/coverage/control.py index afb6137..09bd75f 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -499,6 +499,12 @@ class coverage(object): for src in self.source: for py_file in find_python_files(src): py_file = self.file_locator.canonical_filename(py_file) + + if self.omit_match and self.omit_match.match(py_file): + # Turns out this file was omitted, so don't pull it + # back in as unexecuted. + continue + self.data.touch_file(py_file) self._measured = False diff --git a/tests/test_api.py b/tests/test_api.py index 300a237..097947d 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -430,7 +430,7 @@ class OmitIncludeTestsMixin(UsingModulesMixin): self.filenames_not_in(result, "p1a p1c p2a othera osa") def test_omit_and_include(self): - result = self.coverage_usepkgs( include=["*/p1*"], omit=["*/p1a.py"]) + result = self.coverage_usepkgs(include=["*/p1*"], omit=["*/p1a.py"]) self.filenames_in(result, "p1b") self.filenames_not_in(result, "p1a p1c p2a p2b") @@ -467,6 +467,16 @@ class SourceOmitIncludeTest(OmitIncludeTestsMixin, CoverageTest): self.filenames_in(lines, "p1b") self.filenames_not_in(lines, "p1a p1c p2a p2b othera otherb osa osb") + def test_source_package_part_omitted(self): + # https://bitbucket.org/ned/coveragepy/issue/218 + # Used to be if you omitted something executed and inside the source, + # then after it was executed but not recorded, it would be found in + # the search for unexecuted files, and given a score of 0%. + lines = self.coverage_usepkgs(source=["pkg1"], omit=["pkg1/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.""" |