1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Enabled SimpleTestCase to be decorated by override_settings

Refs #18417. Also fixed some test case classes which subclassed
the wrong parent.
This commit is contained in:
Claude Paroz
2012-11-24 23:47:41 +01:00
parent 9f7cefd505
commit a5d47415f4
4 changed files with 54 additions and 48 deletions

View File

@@ -4,7 +4,7 @@ import warnings
from django.conf import settings, global_settings
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpRequest
from django.test import TransactionTestCase, TestCase, signals
from django.test import SimpleTestCase, TransactionTestCase, TestCase, signals
from django.test.utils import override_settings
from django.utils import unittest, six
@@ -118,19 +118,19 @@ class SettingsTests(TestCase):
self.assertRaises(AttributeError, getattr, settings, 'TEST')
def test_class_decorator(self):
# TransactionTestCase can be decorated by override_settings, but not ut.TestCase
class TransactionTestCaseSubclass(TransactionTestCase):
# SimpleTestCase can be decorated by override_settings, but not ut.TestCase
class SimpleTestCaseSubclass(SimpleTestCase):
pass
class UnittestTestCaseSubclass(unittest.TestCase):
pass
decorated = override_settings(TEST='override')(TransactionTestCaseSubclass)
decorated = override_settings(TEST='override')(SimpleTestCaseSubclass)
self.assertIsInstance(decorated, type)
self.assertTrue(issubclass(decorated, TransactionTestCase))
self.assertTrue(issubclass(decorated, SimpleTestCase))
with six.assertRaisesRegex(self, Exception,
"Only subclasses of Django TransactionTestCase*"):
"Only subclasses of Django SimpleTestCase*"):
decorated = override_settings(TEST='override')(UnittestTestCaseSubclass)
def test_signal_callback_context_manager(self):