diff options
author | Domen Kožar <domen@dev.si> | 2012-08-18 17:39:46 +0200 |
---|---|---|
committer | Domen Kožar <domen@dev.si> | 2012-08-18 17:39:46 +0200 |
commit | 90852641213e1c2528ac97125a61dc63ddfa95b5 (patch) | |
tree | 2c05f5a9127b82c747a4dc7cd63a443532a9aa53 | |
parent | 0035377858a761e0173946fafcc205cf8ae2ab74 (diff) | |
download | nose-90852641213e1c2528ac97125a61dc63ddfa95b5.tar.gz |
more tests
-rw-r--r-- | functional_tests/test_coverage_plugin.py | 28 | ||||
-rw-r--r-- | nose/plugins/cover.py | 2 |
2 files changed, 26 insertions, 4 deletions
diff --git a/functional_tests/test_coverage_plugin.py b/functional_tests/test_coverage_plugin.py index d6fb8a6..717f13a 100644 --- a/functional_tests/test_coverage_plugin.py +++ b/functional_tests/test_coverage_plugin.py @@ -11,7 +11,7 @@ support = os.path.join(os.path.dirname(__file__), 'support') class TestCoveragePlugin(PluginTester, unittest.TestCase): activate = "--with-coverage" - args = ['-v', '--cover-package=blah', '--cover-html'] + args = ['-v', '--cover-package=blah', '--cover-html', '--cover-min-percentage', '25'] plugins = [Coverage()] suitepath = os.path.join(support, 'coverage') @@ -29,7 +29,7 @@ class TestCoveragePlugin(PluginTester, unittest.TestCase): self.assertTrue("Ran 1 test in""" in self.output) # Assert coverage html report exists self.assertTrue(os.path.exists(os.path.join(self.cover_html_dir, - 'index.html'))) + 'index.html'))) # Assert coverage data is saved self.assertTrue(os.path.exists(self.cover_file)) @@ -47,7 +47,29 @@ class TestCoverageMinPercentagePlugin(PluginTester, unittest.TestCase): os.unlink(self.cover_file) if os.path.exists(self.cover_html_dir): shutil.rmtree(self.cover_html_dir) - self.assertRaises(SystemExit, super(TestCoverageMinPercentagePlugin, self).setUp) + self.assertRaises(SystemExit, + super(TestCoverageMinPercentagePlugin, self).setUp) + + def runTest(self): + pass + + +class TestCoverageMinPercentageTOTALPlugin(PluginTester, unittest.TestCase): + activate = "--with-coverage" + args = ['-v', '--cover-package=blah', '--cover-package=moo', + '--cover-min-percentage', '100'] + plugins = [Coverage()] + suitepath = os.path.join(support, 'coverage2') + + def setUp(self): + self.cover_file = os.path.join(os.getcwd(), '.coverage') + self.cover_html_dir = os.path.join(os.getcwd(), 'cover') + if os.path.exists(self.cover_file): + os.unlink(self.cover_file) + if os.path.exists(self.cover_html_dir): + shutil.rmtree(self.cover_html_dir) + self.assertRaises(SystemExit, + super(TestCoverageMinPercentageTOTALPlugin, self).setUp) def runTest(self): pass diff --git a/nose/plugins/cover.py b/nose/plugins/cover.py index 40a8c35..378ebec 100644 --- a/nose/plugins/cover.py +++ b/nose/plugins/cover.py @@ -174,7 +174,7 @@ class Coverage(Plugin): if self.coverMinPercentage: f = StringIO.StringIO() self.coverInstance.report(modules, file=f) - m = re.search(r'TOTAL\s+\d+\s+\d+\s+(\d+)%', f.getvalue()) + m = re.search(r'-------\s\w+\s+\d+\s+\d+\s+(\d+)%\s+\d*\s{0,1}$', f.getvalue()) if m: percentage = int(m.groups()[0]) if percentage < self.coverMinPercentage: |