diff --git a/django/test/testcases.py b/django/test/testcases.py
index 95e751d..7ca17fa 100644
a
|
b
|
class TestCase(TransactionTestCase):
|
849 | 849 | def _deferredSkip(condition, reason): |
850 | 850 | def decorator(test_func): |
851 | 851 | if not (isinstance(test_func, type) and |
852 | | issubclass(test_func, TestCase)): |
| 852 | issubclass(test_func, ut2.TestCase)): |
853 | 853 | @wraps(test_func) |
854 | 854 | def skip_wrapper(*args, **kwargs): |
855 | 855 | if condition(): |
856 | 856 | raise ut2.SkipTest(reason) |
857 | 857 | return test_func(*args, **kwargs) |
858 | 858 | test_item = skip_wrapper |
| 859 | test_item.__unittest_skip_why__ = reason |
| 860 | return test_item |
859 | 861 | else: |
860 | | test_item = test_func |
861 | | test_item.__unittest_skip_why__ = reason |
862 | | return test_item |
| 862 | # Assume a class is decorated |
| 863 | if condition(): |
| 864 | test_func.__unittest_skip__ = True |
| 865 | test_func.__unittest_skip_why__ = reason |
| 866 | return test_func |
863 | 867 | return decorator |
864 | 868 | |
865 | 869 | |
diff --git a/tests/regressiontests/test_utils/tests.py b/tests/regressiontests/test_utils/tests.py
index 46479eb..f37d94d 100644
a
|
b
|
|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | from __future__ import absolute_import, unicode_literals |
3 | 3 | |
| 4 | from io import BytesIO |
| 5 | |
4 | 6 | from django.forms import EmailField, IntegerField |
5 | 7 | from django.http import HttpResponse |
6 | 8 | from django.template.loader import render_to_string |
7 | | from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature |
8 | | from django.utils.unittest import skip |
| 9 | from django.test import SimpleTestCase, TestCase, skipIfDBFeature, skipUnlessDBFeature |
| 10 | from django.utils import unittest |
9 | 11 | |
10 | 12 | from .models import Person |
11 | 13 | |
… |
… |
class SkippingTestCase(TestCase):
|
21 | 23 | self.assertRaises(ValueError, test_func) |
22 | 24 | |
23 | 25 | |
| 26 | class SkippingClassTestCase(TestCase): |
| 27 | def test_skip_class_unless_db_feature(self): |
| 28 | @skipUnlessDBFeature("__class__") |
| 29 | class NotSkippedTests(unittest.TestCase): |
| 30 | def test_dummy(self): |
| 31 | return |
| 32 | |
| 33 | @skipIfDBFeature("__class__") |
| 34 | class SkippedTests(unittest.TestCase): |
| 35 | def test_will_be_skipped(self): |
| 36 | self.fail("We should never arrive here.") |
| 37 | |
| 38 | test_suite = unittest.TestSuite() |
| 39 | test_suite.addTest(NotSkippedTests('test_dummy')) |
| 40 | test_suite.addTest(SkippedTests('test_will_be_skipped')) |
| 41 | result = unittest.TextTestRunner(stream=BytesIO()).run(test_suite) |
| 42 | self.assertEqual(result.testsRun, 2) |
| 43 | self.assertEqual(len(result.skipped), 1) |
| 44 | |
| 45 | |
24 | 46 | class AssertNumQueriesTests(TestCase): |
25 | 47 | urls = 'regressiontests.test_utils.urls' |
26 | 48 | |
… |
… |
class SkippingExtraTests(TestCase):
|
458 | 480 | with self.assertNumQueries(0): |
459 | 481 | super(SkippingExtraTests, self).__call__(result) |
460 | 482 | |
461 | | @skip("Fixture loading should not be performed for skipped tests.") |
| 483 | @unittest.skip("Fixture loading should not be performed for skipped tests.") |
462 | 484 | def test_fixtures_are_skipped(self): |
463 | 485 | pass |
464 | 486 | |