diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-12-26 15:27:49 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-12-26 15:27:49 -0500 |
commit | c3b8f57d2cd96801052fc0d0f56401aaa8d4f063 (patch) | |
tree | 2d113ec8e15177ffa880ec718946aa29f83b8e94 /test/test_coverage.py | |
parent | 04076715a642d0caa6436e81d35416e711b80d52 (diff) | |
download | python-coveragepy-git-c3b8f57d2cd96801052fc0d0f56401aaa8d4f063.tar.gz |
Mark some lines as uncoverable, add some tests for some test methods.
Diffstat (limited to 'test/test_coverage.py')
-rw-r--r-- | test/test_coverage.py | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/test/test_coverage.py b/test/test_coverage.py index 693b9b33..c3a88d71 100644 --- a/test/test_coverage.py +++ b/test/test_coverage.py @@ -13,6 +13,86 @@ sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k from coveragetest import CoverageTest +class TestCoverageTest(CoverageTest): + """Make sure our complex self.check_coverage method works.""" + + def test_successful_coverage(self): + # The simplest run possible. + self.check_coverage("""\ + a = 1 + b = 2 + """, + [1,2] + ) + # You can provide a list of possible statement matches. + self.check_coverage("""\ + a = 1 + b = 2 + """, + ([100], [1,2], [1723,47]), + ) + # You can specify missing lines. + self.check_coverage("""\ + a = 1 + if a == 2: + a = 3 + """, + [1,2,3], + missing="3", + ) + # You can specify a list of possible missing lines. + self.check_coverage("""\ + a = 1 + if a == 2: + a = 3 + """, + [1,2,3], + missing=("47-49", "3", "100,102") + ) + + def test_failed_coverage(self): + # If the lines are wrong, the message shows right and wrong. + self.assertRaisesRegexp(AssertionError, + r"\[1, 2] != \[1]", + self.check_coverage, """\ + a = 1 + b = 2 + """, + [1] + ) + # If the list of lines possibilities is wrong, the msg shows right. + self.assertRaisesRegexp(AssertionError, + r"None of the lines choices matched \[1, 2]", + self.check_coverage, """\ + a = 1 + b = 2 + """, + ([1], [2]) + ) + # If the missing lines are wrong, the message shows right and wrong. + self.assertRaisesRegexp(AssertionError, + r"'3' != '37'", + self.check_coverage, """\ + a = 1 + if a == 2: + a = 3 + """, + [1,2,3], + missing="37", + ) + # If the missing lines possibilities are wrong, the msg shows right. + self.assertRaisesRegexp(AssertionError, + r"None of the missing choices matched '3'", + self.check_coverage, """\ + a = 1 + if a == 2: + a = 3 + """, + [1,2,3], + missing=("37", "4-10"), + ) + + class BasicCoverageTest(CoverageTest): """The simplest tests, for quick smoke testing of fundamental changes.""" |