summaryrefslogtreecommitdiff
path: root/nose/plugins
diff options
context:
space:
mode:
authorIan Wienand <iwienand@redhat.com>2013-06-20 12:57:44 +1000
committerIan Wienand <iwienand@redhat.com>2013-06-20 12:57:44 +1000
commit395a1bff9919f083eba9eb45800692e8ab55728c (patch)
treed0019fe52e3edd0d0342ca0f9d127c5ec6909a97 /nose/plugins
parent1a8262631af0cbd29d12ebea0edc17f0882c76b3 (diff)
downloadnose-395a1bff9919f083eba9eb45800692e8ab55728c.tar.gz
Look for unittest2 in skip plugin
If unittest2 is available, try to use its SkipTest class rather than a nose internal version. Inspired by better integration with testtools for older python releases (see [1]). [1] https://review.openstack.org/#/c/33056/
Diffstat (limited to 'nose/plugins')
-rw-r--r--nose/plugins/skip.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/nose/plugins/skip.py b/nose/plugins/skip.py
index 27e5162..9d1ac8f 100644
--- a/nose/plugins/skip.py
+++ b/nose/plugins/skip.py
@@ -9,15 +9,22 @@ is enabled by default but may be disabled with the ``--no-skip`` option.
from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin
+# on SkipTest:
+# - unittest SkipTest is first preference, but it's only available
+# for >= 2.7
+# - unittest2 SkipTest is second preference for older pythons. This
+# mirrors logic for choosing SkipTest exception in testtools
+# - if none of the above, provide custom class
try:
- # 2.7
from unittest.case import SkipTest
except ImportError:
- # 2.6 and below
- class SkipTest(Exception):
- """Raise this exception to mark a test as skipped.
- """
- pass
+ try:
+ from unittest2.case import SkipTest
+ except ImportError:
+ class SkipTest(Exception):
+ """Raise this exception to mark a test as skipped.
+ """
+ pass
class Skip(ErrorClassPlugin):