From c1a014bba4f25e7d9c6c1a46737bcd5d490a13f7 Mon Sep 17 00:00:00 2001 From: Julien Phalip Date: Tue, 25 Oct 2011 02:55:25 +0000 Subject: [PATCH] Made some `contrib.messages` tests use `override_settings` for clarity. Thanks to Claude Paroz for the patch. Refs #16507, #16574. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17032 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/messages/tests/cookie.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/django/contrib/messages/tests/cookie.py b/django/contrib/messages/tests/cookie.py index f22ed399bc..30aa6b53a6 100644 --- a/django/contrib/messages/tests/cookie.py +++ b/django/contrib/messages/tests/cookie.py @@ -3,8 +3,8 @@ from django.contrib.messages.tests.base import BaseTest from django.contrib.messages.storage.cookie import (CookieStorage, MessageEncoder, MessageDecoder) from django.contrib.messages.storage.base import Message +from django.test.utils import override_settings from django.utils import simplejson as json -from django.conf import settings def set_cookie_data(storage, messages, invalid=False, encode_empty=False): @@ -41,15 +41,6 @@ def stored_cookie_messages_count(storage, response): class CookieTest(BaseTest): storage_class = CookieStorage - def setUp(self): - super(CookieTest, self).setUp() - self.old_SESSION_COOKIE_DOMAIN = settings.SESSION_COOKIE_DOMAIN - settings.SESSION_COOKIE_DOMAIN = '.lawrence.com' - - def tearDown(self): - super(CookieTest, self).tearDown() - settings.SESSION_COOKIE_DOMAIN = self.old_SESSION_COOKIE_DOMAIN - def stored_messages_count(self, storage, response): return stored_cookie_messages_count(storage, response) @@ -139,3 +130,6 @@ class CookieTest(BaseTest): value = encoder.encode(messages) decoded_messages = json.loads(value, cls=MessageDecoder) self.assertEqual(messages, decoded_messages) + +CookieTest = override_settings( + SESSION_COOKIE_DOMAIN='.lawrence.com')(CookieTest)