diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2022-10-23 14:03:17 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2022-10-30 15:45:47 -0400 |
commit | ec6205a8de972af6a09453235d02a7ebea6aea8e (patch) | |
tree | 2e55057dff55197a0466d8189c2bac6b2d03239c /tests/test_summary.py | |
parent | b3a1d979f8625e4974eaa7211cdecb211ba90b50 (diff) | |
download | python-coveragepy-git-ec6205a8de972af6a09453235d02a7ebea6aea8e.tar.gz |
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.
Diffstat (limited to 'tests/test_summary.py')
-rw-r--r-- | tests/test_summary.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_summary.py b/tests/test_summary.py index d603062b..ac29f517 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -138,6 +138,30 @@ class SummaryTest(UsingModulesMixin, CoverageTest): assert "mycode.py " in report assert self.last_line_squeezed(report) == "TOTAL 4 0 100%" + def test_omit_files_here(self): + # https://github.com/nedbat/coveragepy/issues/1407 + self.make_file("foo.py", "") + self.make_file("bar/bar.py", "") + self.make_file("tests/test_baz.py", """\ + def test_foo(): + assert True + test_foo() + """) + self.run_command("coverage run --source=. --omit='./*.py' -m tests.test_baz") + report = self.report_from_command("coverage report") + + # Name Stmts Miss Cover + # --------------------------------------- + # tests/test_baz.py 3 0 100% + # --------------------------------------- + # TOTAL 3 0 100% + + assert self.line_count(report) == 5 + assert "foo" not in report + assert "bar" not in report + assert "tests/test_baz.py" in report + assert self.last_line_squeezed(report) == "TOTAL 3 0 100%" + def test_run_source_vs_report_include(self): # https://github.com/nedbat/coveragepy/issues/621 self.make_file(".coveragerc", """\ |