summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Szakmeister <john@szakmeister.net>2013-03-15 06:22:24 -0700
committerJohn Szakmeister <john@szakmeister.net>2013-03-15 06:22:24 -0700
commitcb9bbf1017b557a17488491c6d599b08d5c45fc1 (patch)
treec1c721b30e9b80575649b57f0c8f38b7f01df763
parentc0f777e488337dc7dde933453799986c46b37deb (diff)
parentbdca77e6f0bf7fbcf4c754f5a7eeb6e7a0f667a3 (diff)
downloadnose-cb9bbf1017b557a17488491c6d599b08d5c45fc1.tar.gz
Merge pull request #657 from jszakmeister/fix-coverage-detection-for-3.3
Correctly detect the coverage module under Python 3.3.
-rw-r--r--functional_tests/test_coverage_plugin.py7
-rw-r--r--nose/plugins/cover.py2
2 files changed, 8 insertions, 1 deletions
diff --git a/functional_tests/test_coverage_plugin.py b/functional_tests/test_coverage_plugin.py
index 3242695..d58a519 100644
--- a/functional_tests/test_coverage_plugin.py
+++ b/functional_tests/test_coverage_plugin.py
@@ -1,5 +1,6 @@
"""Test the coverage plugin."""
import os
+import sys
import unittest
import shutil
@@ -10,7 +11,11 @@ support = os.path.join(os.path.dirname(__file__), 'support')
try:
import coverage
- hasCoverage = True
+
+ # Python 3.3 may accidentally pick up our support area when running the unit
+ # tests. Look for the coverage attribute to make sure we've got the right
+ # package.
+ hasCoverage = hasattr(coverage, 'coverage')
except ImportError:
hasCoverage = False
diff --git a/nose/plugins/cover.py b/nose/plugins/cover.py
index f1f53c8..d041251 100644
--- a/nose/plugins/cover.py
+++ b/nose/plugins/cover.py
@@ -104,6 +104,8 @@ class Coverage(Plugin):
if self.enabled:
try:
import coverage
+ if not hasattr(coverage, 'coverage'):
+ raise ImportError("Unable to import coverage module")
except ImportError:
log.error("Coverage not available: "
"unable to import coverage module")