Ticket #21281: 21281-1.diff

File 21281-1.diff, 1.6 KB (added by Claude Paroz, 11 years ago)
  • django/test/testcases.py

    diff --git a/django/test/testcases.py b/django/test/testcases.py
    index 3ce96b0..bf3b161 100644
    a b class SimpleTestCase(unittest.TestCase):  
    159159    client_class = Client
    160160    _custom_settings = None
    161161
     162    @classmethod
     163    def setUpClass(cls):
     164        if cls._custom_settings:
     165            cls._cls_overridden = override_settings(**cls._custom_settings)
     166            cls._cls_overridden.enable()
     167        super(SimpleTestCase, cls).setUpClass()
     168
     169    @classmethod
     170    def tearDownClass(cls):
     171        super(SimpleTestCase, cls).tearDownClass()
     172        if cls._custom_settings:
     173            cls._cls_overridden.disable()
     174
    162175    def __call__(self, result=None):
    163176        """
    164177        Wrapper around default __call__ method to perform common Django test
  • tests/settings_tests/tests.py

    diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py
    index 4a0c363..236f8b4 100644
    a b class ClassDecoratedTestCaseSuper(TestCase):  
    5454
    5555@override_settings(TEST='override')
    5656class ClassDecoratedTestCase(ClassDecoratedTestCaseSuper):
     57    @classmethod
     58    def setUpClass(cls):
     59        super(cls, ClassDecoratedTestCase).setUpClass()
     60        cls.foo = getattr(settings, 'TEST', 'BUG')
     61
    5762    def test_override(self):
    5863        self.assertEqual(settings.TEST, 'override')
    5964
     65    def test_setupclass_override(self):
     66        self.assertNotEqual(self.foo, 'BUG')
     67
    6068    @override_settings(TEST='override2')
    6169    def test_method_override(self):
    6270        self.assertEqual(settings.TEST, 'override2')
Back to Top