Commit 27eb8bbf authored by Ramiro Morales's avatar Ramiro Morales
Browse files

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
parent 4fc3741e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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()
+13 −1
Original line number Diff line number Diff line
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):