From 27eb8bbfd09594e3f0f40391ca1a06b896acebdf Mon Sep 17 00:00:00 2001 From: Ramiro Morales Date: Wed, 10 Aug 2011 22:26:34 +0000 Subject: [PATCH] Made override_settings also work with TransactionTestCase when acting as a class decorator. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16592 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/test/utils.py | 4 ++-- tests/regressiontests/settings_tests/tests.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/django/test/utils.py b/django/test/utils.py index dbb1c20163..88da9d54c5 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -194,8 +194,8 @@ class override_settings(object): self.disable() def __call__(self, test_func): - from django.test import TestCase - if isinstance(test_func, type) and issubclass(test_func, TestCase): + from django.test import TransactionTestCase + if isinstance(test_func, type) and issubclass(test_func, TransactionTestCase): class inner(test_func): def _pre_setup(innerself): self.enable() diff --git a/tests/regressiontests/settings_tests/tests.py b/tests/regressiontests/settings_tests/tests.py index 369ab30aa4..9715046bd4 100644 --- a/tests/regressiontests/settings_tests/tests.py +++ b/tests/regressiontests/settings_tests/tests.py @@ -1,10 +1,22 @@ from __future__ import with_statement import os from django.conf import settings, global_settings -from django.test import TestCase, signals +from django.test import TransactionTestCase, TestCase, signals from django.test.utils import override_settings +# @override_settings(TEST='override') +class FullyDecoratedTranTestCase(TransactionTestCase): + + def test_override(self): + self.assertEqual(settings.TEST, 'override') + + @override_settings(TEST='override2') + def test_method_override(self): + self.assertEqual(settings.TEST, 'override2') + +FullyDecoratedTranTestCase = override_settings(TEST='override')(FullyDecoratedTranTestCase) + # @override_settings(TEST='override') class FullyDecoratedTestCase(TestCase):