Ticket #14049: 14049.diff

File 14049.diff, 2.0 KB (added by Ramiro Morales, 13 years ago)
  • django/test/testcases.py

    diff --git a/django/test/testcases.py b/django/test/testcases.py
    a b  
    282282        set up. This means that user-defined Test Cases aren't required to
    283283        include a call to super().setUp().
    284284        """
     285        testMethod = getattr(self, self._testMethodName)
     286        if (getattr(self.__class__, "__unittest_skip__", False) or
     287            getattr(testMethod, "__unittest_skip__", False)):
     288            return
     289
    285290        self.client = self.client_class()
    286291        try:
    287292            self._pre_setup()
  • new file tests/regressiontests/test_utils/fixtures/should_not_be_loaded.json

    diff --git a/tests/regressiontests/test_utils/fixtures/should_not_be_loaded.json b/tests/regressiontests/test_utils/fixtures/should_not_be_loaded.json
    new file mode 100644
    - +  
     1[
     2    {
     3        "pk": 1,
     4        "model": "test_utils.person",
     5        "fields": {
     6            "name": "Elvis Presley"
     7        }
     8    }
     9]
     10
  • tests/regressiontests/test_utils/tests.py

    diff --git a/tests/regressiontests/test_utils/tests.py b/tests/regressiontests/test_utils/tests.py
    a b  
    33import sys
    44
    55from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
     6from django.utils.unittest import skip
    67
    78from models import Person
    89
     
    115116        # Remove the filter we just added.
    116117        self.restore_warnings_state()
    117118
     119
     120class 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
    118134__test__ = {"API_TEST": r"""
    119135# Some checks of the doctest output normalizer.
    120136# Standard doctests do fairly
Back to Top