diff options
author | Steve <sleonard76@gmail.com> | 2014-05-26 13:26:02 -0400 |
---|---|---|
committer | Steve <sleonard76@gmail.com> | 2014-05-26 13:26:02 -0400 |
commit | a91fb5b97886f23f78deaaaeb42daf20b898acff (patch) | |
tree | 675c179b894c19e7d341e3ab62ae44eecb5c8d0c | |
parent | bb18cef4f20b7035e78116594f478742e29966d5 (diff) | |
download | python-coveragepy-a91fb5b97886f23f78deaaaeb42daf20b898acff.tar.gz |
Tests for --branch --show-missing summary; update AUTHORS.txt
-rw-r--r-- | AUTHORS.txt | 1 | ||||
-rw-r--r-- | tests/test_summary.py | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/AUTHORS.txt b/AUTHORS.txt index d7e2d27..a30f377 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -43,3 +43,4 @@ Sigve Tjora Mark van der Wal Zooko Wilcox-O'Hearn Christoph Zwerschke +Steve Leonard diff --git a/tests/test_summary.py b/tests/test_summary.py index 79e3216..61bdf37 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -142,6 +142,55 @@ class SummaryTest(CoverageTest): self.assertEqual(self.last_line_squeezed(report), "mybranch 5 0 2 1 86%") + def test_report_show_missing(self): + self.make_file("mymissing.py", """\ + def missing(x, y): + if x: + print("x") + return x + if y: + print("y") + return x + return y + missing(0, 1) + """) + out = self.run_command("coverage run mymissing.py") + self.assertEqual(out, 'y\n') + report = self.report_from_command("coverage report --show-missing") + + # Name Stmts Miss Cover Missing + # ----------------------------------------- + # tests/tmp 9 3 67% 3-4, 8 + + self.assertEqual(self.line_count(report), 3) + self.assertIn("mymissing ", report) + self.assertEqual(self.last_line_squeezed(report), + "mymissing 9 3 67% 3-4, 8") + + def test_report_show_missing_branches(self): + self.make_file("mybranch.py", """\ + def branch(x, y): + if x: + print("x") + if y: + print("y") + return x + branch(1, 0) + """) + out = self.run_command("coverage run --branch mybranch.py") + self.assertEqual(out, 'x\n') + report = self.report_from_command("coverage report --show-missing") + + # pylint: disable=C0301 + # Name Stmts Miss Branch BrMiss Cover Missing + # ------------------------------------------------------- + # mybranch 7 1 4 2 73% 5, Branches: 2->4, 4->5 + + self.assertEqual(self.line_count(report), 3) + self.assertIn("mybranch ", report) + self.assertEqual(self.last_line_squeezed(report), + "mybranch 7 1 4 2 73% 5, Branches: 2->4, 4->5") + def test_dotpy_not_python(self): # We run a .py file, and when reporting, we can't parse it as Python. # We should get an error message in the report. |