Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #14049 -- Made our TestCase subclasses not load database fixtur…

…es (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
  • Loading branch information...
commit 4ab5a43785418a8bb46bcc480a1cf73bde631e2f 1 parent 703498b
Ramiro Morales authored June 11, 2011
5  django/test/testcases.py
@@ -282,6 +282,11 @@ def __call__(self, result=None):
282 282
         set up. This means that user-defined Test Cases aren't required to
283 283
         include a call to super().setUp().
284 284
         """
  285
+        testMethod = getattr(self, self._testMethodName)
  286
+        if (getattr(self.__class__, "__unittest_skip__", False) or
  287
+            getattr(testMethod, "__unittest_skip__", False)):
  288
+            return
  289
+
285 290
         self.client = self.client_class()
286 291
         try:
287 292
             self._pre_setup()
16  tests/regressiontests/test_utils/tests.py
@@ -3,6 +3,7 @@
3 3
 import sys
4 4
 
5 5
 from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
  6
+from django.utils.unittest import skip
6 7
 
7 8
 from models import Person
8 9
 
@@ -115,6 +116,21 @@ class MyWarning(Warning):
115 116
         # Remove the filter we just added.
116 117
         self.restore_warnings_state()
117 118
 
  119
+
  120
+class SkippingExtraTests(TestCase):
  121
+    fixtures = ['should_not_be_loaded.json']
  122
+
  123
+    # HACK: This depends on internals of our TestCase subclasses
  124
+    def __call__(self, result=None):
  125
+        # Detect fixture loading by counting SQL queries, should be zero
  126
+        with self.assertNumQueries(0):
  127
+            super(SkippingExtraTests, self).__call__(result)
  128
+
  129
+    @skip("Fixture loading should not be performed for skipped tests.")
  130
+    def test_fixtures_are_skipped(self):
  131
+        pass
  132
+
  133
+
118 134
 __test__ = {"API_TEST": r"""
119 135
 # Some checks of the doctest output normalizer.
120 136
 # Standard doctests do fairly

0 notes on commit 4ab5a43

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