Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Corrected the skipIfDBFeature and skipUnlessDBFeature decorators to a…

…ctually *run* the tests they decorate. Thanks to Alex for the report and patch.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 400125d718c6a005d81c7ed051a15687394c2743 1 parent cd63ce0
@freakboy3742 freakboy3742 authored
9 django/test/
@@ -576,13 +576,16 @@ def _fixture_teardown(self):
def _deferredSkip(condition, reason):
- def decorator(test_item):
- if not (isinstance(test_item, type) and issubclass(test_item, TestCase)):
- @wraps(test_item)
+ def decorator(test_func):
+ if not (isinstance(test_func, type) and issubclass(test_func, TestCase)):
+ @wraps(test_func)
def skip_wrapper(*args, **kwargs):
if condition():
raise unittest.SkipTest(reason)
+ return test_func(*args, **kwargs)
test_item = skip_wrapper
+ else:
+ test_item = test_func
test_item.__unittest_skip_why__ = reason
return test_item
return decorator
14 tests/regressiontests/test_utils/
@@ -1,9 +1,23 @@
import sys
+from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
if sys.version_info >= (2, 5):
from python_25 import AssertNumQueriesTests
+class SkippingTestCase(TestCase):
+ def test_skip_unless_db_feature(self):
+ "A test that might be skipped is actually called."
+ # Total hack, but it works, just want an attribute that's always true.
+ @skipUnlessDBFeature("__class__")
+ def test_func():
+ raise ValueError
+ self.assertRaises(ValueError, test_func)
__test__ = {"API_TEST": r"""
# Some checks of the doctest output normalizer.
# Standard doctests do fairly

0 comments on commit 400125d

Please sign in to comment.
Something went wrong with that request. Please try again.