summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2011-06-11 15:27:12 +0000
committerRamiro Morales <cramm0@gmail.com>2011-06-11 15:27:12 +0000
commit4ab5a43785418a8bb46bcc480a1cf73bde631e2f (patch)
tree4df90397c3230c70bec500ac8e1c53d1b7737b06
parent703498b1c86678c287de8a44c08724b4e67c4e40 (diff)
Fixed #14049 -- Made our TestCase subclasses not load database fixtures (nor set up custom URLconfs) for test methods that are going to be skipped. Thanks zimnyx for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16369 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/test/testcases.py5
-rw-r--r--tests/regressiontests/test_utils/tests.py16
2 files changed, 21 insertions, 0 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py
index bfa1aeb219..02717ffaa7 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -282,6 +282,11 @@ class TransactionTestCase(ut2.TestCase):
set up. This means that user-defined Test Cases aren't required to
include a call to super().setUp().
"""
+ testMethod = getattr(self, self._testMethodName)
+ if (getattr(self.__class__, "__unittest_skip__", False) or
+ getattr(testMethod, "__unittest_skip__", False)):
+ return
+
self.client = self.client_class()
try:
self._pre_setup()
diff --git a/tests/regressiontests/test_utils/tests.py b/tests/regressiontests/test_utils/tests.py
index f4b836a792..673295be37 100644
--- a/tests/regressiontests/test_utils/tests.py
+++ b/tests/regressiontests/test_utils/tests.py
@@ -3,6 +3,7 @@ from __future__ import with_statement
import sys
from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
+from django.utils.unittest import skip
from models import Person
@@ -115,6 +116,21 @@ class SaveRestoreWarningState(TestCase):
# Remove the filter we just added.
self.restore_warnings_state()
+
+class SkippingExtraTests(TestCase):
+ fixtures = ['should_not_be_loaded.json']
+
+ # HACK: This depends on internals of our TestCase subclasses
+ def __call__(self, result=None):
+ # Detect fixture loading by counting SQL queries, should be zero
+ with self.assertNumQueries(0):
+ super(SkippingExtraTests, self).__call__(result)
+
+ @skip("Fixture loading should not be performed for skipped tests.")
+ def test_fixtures_are_skipped(self):
+ pass
+
+
__test__ = {"API_TEST": r"""
# Some checks of the doctest output normalizer.
# Standard doctests do fairly