From b07a08385fd1a32307bce6d3c423276b33ff749c Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 23 Oct 2022 15:06:33 -0400 Subject: [PATCH] test: add a test for #1407 --- tests/test_summary.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_summary.py b/tests/test_summary.py index d603062be..ac29f5175 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -138,6 +138,30 @@ def test_report_including(self): 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", """\