Fixed #21281 -- Made override_settings act at class level when used as a TestCase decorator.

This commit is contained in:
Thomas Chaumeny 2014-10-18 20:03:10 +02:00 committed by Tim Graham
parent 8b77b64f1c
commit d89f56dc4d
9 changed files with 73 additions and 27 deletions

View file

@ -28,6 +28,7 @@ from django.middleware.csrf import CsrfViewMiddleware
from django.template import Template
from django.template.response import TemplateResponse
from django.test import TestCase, TransactionTestCase, RequestFactory, override_settings
from django.test.signals import setting_changed
from django.test.utils import IgnoreDeprecationWarningsMixin
from django.utils import six
from django.utils import timezone
@ -1144,8 +1145,12 @@ class FileBasedCacheTests(BaseCacheTests, TestCase):
def setUp(self):
super(FileBasedCacheTests, self).setUp()
self.dirname = tempfile.mkdtemp()
# Caches location cannot be modified through override_settings / modify_settings,
# hence settings are manipulated directly here and the setting_changed signal
# is triggered manually.
for cache_params in settings.CACHES.values():
cache_params.update({'LOCATION': self.dirname})
setting_changed.send(self.__class__, setting='CACHES', enter=False)
def tearDown(self):
super(FileBasedCacheTests, self).tearDown()