diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-03 22:17:35 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-03 22:17:35 -0400 |
commit | 99a352c787ad1b214b601b7cbc7c5c82fd9b84fe (patch) | |
tree | faf43834ede0a0ca505a7da5f1b0029da30bb418 /test/test_process.py | |
parent | 69e0a37098edba20e24fe8fa80e6960c53e2c3c7 (diff) | |
download | python-coveragepy-git-99a352c787ad1b214b601b7cbc7c5c82fd9b84fe.tar.gz |
Issue #139: Now the report, html, and xml commands take a --fail-under=MIN switch, and exit with 2 if the coverage is less than MIN.
Diffstat (limited to 'test/test_process.py')
-rw-r--r-- | test/test_process.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/test_process.py b/test/test_process.py index f8d1b8d1..9f8aacca 100644 --- a/test/test_process.py +++ b/test/test_process.py @@ -382,3 +382,36 @@ class ProcessTest(CoverageTest): # imported is 120 or so. Just running os.getenv executes # about 5. self.assertGreater(data.summary()['os.py'], 50) + +class FailUnderTest(CoverageTest): + """Tests of the --fail-under switch.""" + + def setUp(self): + super(FailUnderTest, self).setUp() + self.make_file("fifty.py", """\ + # I have 50% coverage! + a = 1 + if a > 2: + b = 3 + c = 4 + """) + status, out = self.run_command_status("coverage run fifty.py", 0) + self.assertEqual(status, 0) + + def test_report(self): + status, out = self.run_command_status("coverage report --fail-under=50", 0) + self.assertEqual(status, 0) + status, out = self.run_command_status("coverage report --fail-under=51", 2) + self.assertEqual(status, 2) + + def test_html_report(self): + status, out = self.run_command_status("coverage html --fail-under=50", 0) + self.assertEqual(status, 0) + status, out = self.run_command_status("coverage html --fail-under=51", 2) + self.assertEqual(status, 2) + + def test_xml_report(self): + status, out = self.run_command_status("coverage xml --fail-under=50", 0) + self.assertEqual(status, 0) + status, out = self.run_command_status("coverage xml --fail-under=51", 2) + self.assertEqual(status, 2) |