Last active
December 10, 2015 23:29
-
-
Save mitya57/4510209 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 67c9502672a5ee87fe1a7d493fb277fc7ff69cdf Mon Sep 17 00:00:00 2001 | |
From: Dmitry Shachnev <[email protected]> | |
Date: Fri, 11 Jan 2013 15:33:38 +0400 | |
Subject: [PATCH] test_coverage_plugin.py: skip the tests when coverage is not | |
available (closes #597) | |
--- | |
functional_tests/test_coverage_plugin.py | 17 ++++++++++++++++- | |
1 file changed, 16 insertions(+), 1 deletion(-) | |
diff --git a/functional_tests/test_coverage_plugin.py b/functional_tests/test_coverage_plugin.py | |
index 717f13a..3242695 100644 | |
--- a/functional_tests/test_coverage_plugin.py | |
+++ b/functional_tests/test_coverage_plugin.py | |
@@ -8,6 +8,12 @@ from nose.plugins.cover import Coverage | |
support = os.path.join(os.path.dirname(__file__), 'support') | |
+try: | |
+ import coverage | |
+ hasCoverage = True | |
+except ImportError: | |
+ hasCoverage = False | |
+ | |
class TestCoveragePlugin(PluginTester, unittest.TestCase): | |
activate = "--with-coverage" | |
@@ -16,6 +22,9 @@ class TestCoveragePlugin(PluginTester, unittest.TestCase): | |
suitepath = os.path.join(support, 'coverage') | |
def setUp(self): | |
+ if not hasCoverage: | |
+ raise unittest.SkipTest('coverage not available; skipping') | |
+ | |
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): | |
@@ -26,7 +35,7 @@ class TestCoveragePlugin(PluginTester, unittest.TestCase): | |
def runTest(self): | |
self.assertTrue("blah 4 3 25% 1" in self.output) | |
- self.assertTrue("Ran 1 test in""" in self.output) | |
+ 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'))) | |
@@ -41,6 +50,9 @@ class TestCoverageMinPercentagePlugin(PluginTester, unittest.TestCase): | |
suitepath = os.path.join(support, 'coverage') | |
def setUp(self): | |
+ if not hasCoverage: | |
+ raise unittest.SkipTest('coverage not available; skipping') | |
+ | |
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): | |
@@ -62,6 +74,9 @@ class TestCoverageMinPercentageTOTALPlugin(PluginTester, unittest.TestCase): | |
suitepath = os.path.join(support, 'coverage2') | |
def setUp(self): | |
+ if not hasCoverage: | |
+ raise unittest.SkipTest('coverage not available; skipping') | |
+ | |
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): | |
-- | |
1.7.10.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment