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 | 2ed120a530c3563056dba02562fbf9df642d13a6 (patch) | |
tree | 46177baa64968af6a3ce10320e1054a1e5e1cbd0 /test/test_process.py | |
parent | 82f9dd6e35c811eb53051f70ebf51bea2740f9dd (diff) | |
download | python-coveragepy-2ed120a530c3563056dba02562fbf9df642d13a6.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 f8d1b8d..9f8aacc 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) |