Author: aaugustin
Date: 2012-03-30 02:08:29 -0700 (Fri, 30 Mar 2012)
New Revision: 17829

Modified:
   django/trunk/django/contrib/auth/tests/context_processors.py
   django/trunk/django/contrib/auth/tests/forms.py
   django/trunk/django/contrib/auth/tests/hashers.py
   django/trunk/django/contrib/auth/tests/models.py
   django/trunk/django/contrib/auth/tests/signals.py
   django/trunk/django/contrib/auth/tests/views.py
   django/trunk/django/contrib/messages/tests/cookie.py
   django/trunk/django/contrib/sessions/tests.py
   django/trunk/django/contrib/sitemaps/tests/https.py
   django/trunk/docs/topics/testing.txt
   django/trunk/tests/modeltests/proxy_model_inheritance/tests.py
   django/trunk/tests/modeltests/timezones/tests.py
   django/trunk/tests/regressiontests/admin_views/tests.py
   django/trunk/tests/regressiontests/cache/tests.py
   django/trunk/tests/regressiontests/forms/tests/media.py
   django/trunk/tests/regressiontests/i18n/contenttypes/tests.py
   django/trunk/tests/regressiontests/i18n/patterns/tests.py
   django/trunk/tests/regressiontests/middleware/tests.py
   django/trunk/tests/regressiontests/settings_tests/tests.py
   django/trunk/tests/regressiontests/staticfiles_tests/tests.py
Log:
Use the class decorator syntax available in Python >= 2.6. Refs #17965.


Modified: django/trunk/django/contrib/auth/tests/context_processors.py
===================================================================
--- django/trunk/django/contrib/auth/tests/context_processors.py        
2012-03-30 08:02:08 UTC (rev 17828)
+++ django/trunk/django/contrib/auth/tests/context_processors.py        
2012-03-30 09:08:29 UTC (rev 17829)
@@ -8,6 +8,12 @@
 from django.test.utils import override_settings
 
 
+@override_settings(
+    TEMPLATE_DIRS=(
+            os.path.join(os.path.dirname(__file__), 'templates'),
+        ),
+    USE_TZ=False,                           # required for loading the fixture
+)
 class AuthContextProcessorTests(TestCase):
     """
     Tests for the ``django.contrib.auth.context_processors.auth`` processor
@@ -95,10 +101,3 @@
         # See bug #12060
         self.assertEqual(response.context['user'], user)
         self.assertEqual(user, response.context['user'])
-
-AuthContextProcessorTests = override_settings(
-    TEMPLATE_DIRS=(
-            os.path.join(os.path.dirname(__file__), 'templates'),
-        ),
-    USE_TZ=False,                           # required for loading the fixture
-)(AuthContextProcessorTests)

Modified: django/trunk/django/contrib/auth/tests/forms.py
===================================================================
--- django/trunk/django/contrib/auth/tests/forms.py     2012-03-30 08:02:08 UTC 
(rev 17828)
+++ django/trunk/django/contrib/auth/tests/forms.py     2012-03-30 09:08:29 UTC 
(rev 17829)
@@ -11,6 +11,7 @@
 from django.utils.translation import ugettext as _
 
 
+@override_settings(USE_TZ=False)
 class UserCreationFormTest(TestCase):
 
     fixtures = ['authtestdata.json']
@@ -75,9 +76,8 @@
         u = form.save()
         self.assertEqual(repr(u), '<User: jsm...@example.com>')
 
-UserCreationFormTest = override_settings(USE_TZ=False)(UserCreationFormTest)
 
-
+@override_settings(USE_TZ=False)
 class AuthenticationFormTest(TestCase):
 
     fixtures = ['authtestdata.json']
@@ -128,9 +128,8 @@
         self.assertTrue(form.is_valid())
         self.assertEqual(form.non_field_errors(), [])
 
-AuthenticationFormTest = 
override_settings(USE_TZ=False)(AuthenticationFormTest)
 
-
+@override_settings(USE_TZ=False)
 class SetPasswordFormTest(TestCase):
 
     fixtures = ['authtestdata.json']
@@ -156,9 +155,8 @@
         form = SetPasswordForm(user, data)
         self.assertTrue(form.is_valid())
 
-SetPasswordFormTest = override_settings(USE_TZ=False)(SetPasswordFormTest)
 
-
+@override_settings(USE_TZ=False)
 class PasswordChangeFormTest(TestCase):
 
     fixtures = ['authtestdata.json']
@@ -205,9 +203,8 @@
         self.assertEqual(PasswordChangeForm(user, {}).fields.keys(),
                          ['old_password', 'new_password1', 'new_password2'])
 
-PasswordChangeFormTest = 
override_settings(USE_TZ=False)(PasswordChangeFormTest)
 
-
+@override_settings(USE_TZ=False)
 class UserChangeFormTest(TestCase):
 
     fixtures = ['authtestdata.json']
@@ -254,9 +251,7 @@
         form.as_table()
 
 
-UserChangeFormTest = override_settings(USE_TZ=False)(UserChangeFormTest)
-
-
+@override_settings(USE_TZ=False)
 class PasswordResetFormTest(TestCase):
 
     fixtures = ['authtestdata.json']
@@ -334,5 +329,3 @@
         self.assertFalse(form.is_valid())
         self.assertEqual(form["email"].errors,
                          [_(u"The user account associated with this e-mail 
address cannot reset the password.")])
-
-PasswordResetFormTest = override_settings(USE_TZ=False)(PasswordResetFormTest)

Modified: django/trunk/django/contrib/auth/tests/hashers.py
===================================================================
--- django/trunk/django/contrib/auth/tests/hashers.py   2012-03-30 08:02:08 UTC 
(rev 17828)
+++ django/trunk/django/contrib/auth/tests/hashers.py   2012-03-30 09:08:29 UTC 
(rev 17829)
@@ -4,7 +4,6 @@
     PBKDF2SHA1PasswordHasher, get_hasher, UNUSABLE_PASSWORD)
 from django.utils import unittest
 from django.utils.unittest import skipUnless
-from django.test.utils import override_settings
 
 
 try:
@@ -19,6 +18,7 @@
 
 
 class TestUtilsHashPass(unittest.TestCase):
+
     def setUp(self):
         load_hashers(password_hashers=default_hashers)
 

Modified: django/trunk/django/contrib/auth/tests/models.py
===================================================================
--- django/trunk/django/contrib/auth/tests/models.py    2012-03-30 08:02:08 UTC 
(rev 17828)
+++ django/trunk/django/contrib/auth/tests/models.py    2012-03-30 09:08:29 UTC 
(rev 17829)
@@ -5,6 +5,7 @@
     SiteProfileNotAvailable, UserManager)
 
 
+@override_settings(USE_TZ=False)
 class ProfileTestCase(TestCase):
     fixtures = ['authtestdata.json']
 
@@ -38,9 +39,8 @@
         settings.AUTH_PROFILE_MODULE = 'foo.bar'
         self.assertRaises(SiteProfileNotAvailable, user.get_profile)
 
-ProfileTestCase = override_settings(USE_TZ=False)(ProfileTestCase)
 
-
+@override_settings(USE_TZ=False)
 class NaturalKeysTestCase(TestCase):
     fixtures = ['authtestdata.json']
 
@@ -53,9 +53,8 @@
         users_group = Group.objects.create(name='users')
         self.assertEquals(Group.objects.get_by_natural_key('users'), 
users_group)
 
-NaturalKeysTestCase = override_settings(USE_TZ=False)(NaturalKeysTestCase)
 
-
+@override_settings(USE_TZ=False)
 class LoadDataWithoutNaturalKeysTestCase(TestCase):
     fixtures = ['regular.json']
 
@@ -64,9 +63,8 @@
         group = Group.objects.get(name='my_group')
         self.assertEquals(group, user.groups.get())
 
-LoadDataWithoutNaturalKeysTestCase = 
override_settings(USE_TZ=False)(LoadDataWithoutNaturalKeysTestCase)
 
-
+@override_settings(USE_TZ=False)
 class LoadDataWithNaturalKeysTestCase(TestCase):
     fixtures = ['natural.json']
 
@@ -75,9 +73,7 @@
         group = Group.objects.get(name='my_group')
         self.assertEquals(group, user.groups.get())
 
-LoadDataWithNaturalKeysTestCase = 
override_settings(USE_TZ=False)(LoadDataWithNaturalKeysTestCase)
 
-
 class UserManagerTestCase(TestCase):
 
     def test_create_user(self):

Modified: django/trunk/django/contrib/auth/tests/signals.py
===================================================================
--- django/trunk/django/contrib/auth/tests/signals.py   2012-03-30 08:02:08 UTC 
(rev 17828)
+++ django/trunk/django/contrib/auth/tests/signals.py   2012-03-30 09:08:29 UTC 
(rev 17829)
@@ -3,6 +3,7 @@
 from django.contrib.auth import signals
 
 
+@override_settings(USE_TZ=False)
 class SignalTestCase(TestCase):
     urls = 'django.contrib.auth.tests.urls'
     fixtures = ['authtestdata.json']
@@ -46,5 +47,3 @@
         self.client.get('/logout/next_page/')
         self.assertEqual(len(self.logged_out), 1)
         self.assertEqual(self.logged_out[0].username, 'testclient')
-
-SignalTestCase = override_settings(USE_TZ=False)(SignalTestCase)

Modified: django/trunk/django/contrib/auth/tests/views.py
===================================================================
--- django/trunk/django/contrib/auth/tests/views.py     2012-03-30 08:02:08 UTC 
(rev 17828)
+++ django/trunk/django/contrib/auth/tests/views.py     2012-03-30 09:08:29 UTC 
(rev 17829)
@@ -18,6 +18,7 @@
                 SetPasswordForm, PasswordResetForm)
 
 
+@override_settings(USE_TZ=False)
 class AuthViewsTestCase(TestCase):
     """
     Helper base class for all the follow test cases.
@@ -52,9 +53,7 @@
     def assertContainsEscaped(self, response, text, **kwargs):
         return self.assertContains(response, escape(force_unicode(text)), 
**kwargs)
 
-AuthViewsTestCase = override_settings(USE_TZ=False)(AuthViewsTestCase)
 
-
 class AuthViewNamedURLTests(AuthViewsTestCase):
     urls = 'django.contrib.auth.urls'
 

Modified: django/trunk/django/contrib/messages/tests/cookie.py
===================================================================
--- django/trunk/django/contrib/messages/tests/cookie.py        2012-03-30 
08:02:08 UTC (rev 17828)
+++ django/trunk/django/contrib/messages/tests/cookie.py        2012-03-30 
09:08:29 UTC (rev 17829)
@@ -38,6 +38,7 @@
     return len(data)
 
 
+@override_settings(SESSION_COOKIE_DOMAIN='.lawrence.com')
 class CookieTest(BaseTest):
     storage_class = CookieStorage
 
@@ -130,6 +131,3 @@
         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)

Modified: django/trunk/django/contrib/sessions/tests.py
===================================================================
--- django/trunk/django/contrib/sessions/tests.py       2012-03-30 08:02:08 UTC 
(rev 17828)
+++ django/trunk/django/contrib/sessions/tests.py       2012-03-30 09:08:29 UTC 
(rev 17829)
@@ -287,7 +287,9 @@
         self.assertEqual(self.session['y'], 2)
 
 
-DatabaseSessionWithTimeZoneTests = 
override_settings(USE_TZ=True)(DatabaseSessionTests)
+@override_settings(USE_TZ=True)
+class DatabaseSessionWithTimeZoneTests(DatabaseSessionTests):
+    pass
 
 
 class CacheDBSessionTests(SessionTestsMixin, TestCase):
@@ -308,7 +310,9 @@
         restore_warnings_state(warnings_state)
 
 
-CacheDBSessionWithTimeZoneTests = 
override_settings(USE_TZ=True)(CacheDBSessionTests)
+@override_settings(USE_TZ=True)
+class CacheDBSessionWithTimeZoneTests(CacheDBSessionTests):
+    pass
 
 
 # Don't need DB flushing for these tests, so can use unittest.TestCase as base 
class

Modified: django/trunk/django/contrib/sitemaps/tests/https.py
===================================================================
--- django/trunk/django/contrib/sitemaps/tests/https.py 2012-03-30 08:02:08 UTC 
(rev 17828)
+++ django/trunk/django/contrib/sitemaps/tests/https.py 2012-03-30 09:08:29 UTC 
(rev 17829)
@@ -26,7 +26,8 @@
 </urlset>
 """ % (self.base_url, date.today()))
 
-#@override_settings(SECURE_PROXY_SSL_HEADER=False)
+
+@override_settings(SECURE_PROXY_SSL_HEADER=False)
 class HTTPSDetectionSitemapTests(SitemapTestsBase):
     extra = {'wsgi.url_scheme': 'https'}
 
@@ -47,5 +48,3 @@
 
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
 </urlset>
 """ % (self.base_url.replace('http://', 'https://'), date.today()))
-
-HTTPSDetectionSitemapTests = 
override_settings(SECURE_PROXY_SSL_HEADER=False)(HTTPSDetectionSitemapTests)

Modified: django/trunk/docs/topics/testing.txt
===================================================================
--- django/trunk/docs/topics/testing.txt        2012-03-30 08:02:08 UTC (rev 
17828)
+++ django/trunk/docs/topics/testing.txt        2012-03-30 09:08:29 UTC (rev 
17829)
@@ -1450,14 +1450,13 @@
     from django.test import TestCase
     from django.test.utils import override_settings
 
+    @override_settings(LOGIN_URL='/other/login/')
     class LoginTestCase(TestCase):
 
         def test_login(self):
             response = self.client.get('/sekrit/')
             self.assertRedirects(response, '/other/login/?next=/sekrit/')
 
-    LoginTestCase = override_settings(LOGIN_URL='/other/login/')(LoginTestCase)
-
 .. note::
 
     When given a class, the decorator modifies the class directly and
@@ -1467,19 +1466,6 @@
     the original ``LoginTestCase`` is still equally affected by the
     decorator.
 
-On Python 2.6 and higher you can also use the well known decorator syntax to
-decorate the class::
-
-    from django.test import TestCase
-    from django.test.utils import override_settings
-
-    @override_settings(LOGIN_URL='/other/login/')
-    class LoginTestCase(TestCase):
-
-        def test_login(self):
-            response = self.client.get('/sekrit/')
-            self.assertRedirects(response, '/other/login/?next=/sekrit/')
-
 .. note::
 
     When overriding settings, make sure to handle the cases in which your app's

Modified: django/trunk/tests/modeltests/proxy_model_inheritance/tests.py
===================================================================
--- django/trunk/tests/modeltests/proxy_model_inheritance/tests.py      
2012-03-30 08:02:08 UTC (rev 17828)
+++ django/trunk/tests/modeltests/proxy_model_inheritance/tests.py      
2012-03-30 09:08:29 UTC (rev 17829)
@@ -18,7 +18,7 @@
 from django.test.utils import override_settings
 
 
-# @override_settings(INSTALLED_APPS=('app1', 'app2'))
+@override_settings(INSTALLED_APPS=('app1', 'app2'))
 class ProxyModelInheritanceTests(TransactionTestCase):
 
     def setUp(self):
@@ -41,5 +41,3 @@
         from .app2.models import NiceModel
         self.assertEqual(NiceModel.objects.all().count(), 0)
         self.assertEqual(ProxyModel.objects.all().count(), 0)
-
-ProxyModelInheritanceTests = override_settings(INSTALLED_APPS=('app1', 
'app2'))(ProxyModelInheritanceTests)

Modified: django/trunk/tests/modeltests/timezones/tests.py
===================================================================
--- django/trunk/tests/modeltests/timezones/tests.py    2012-03-30 08:02:08 UTC 
(rev 17828)
+++ django/trunk/tests/modeltests/timezones/tests.py    2012-03-30 09:08:29 UTC 
(rev 17829)
@@ -74,7 +74,7 @@
             time.tzset()
 
 
-#@override_settings(USE_TZ=False)
+@override_settings(USE_TZ=False)
 class LegacyDatabaseTests(BaseDateTimeTests):
 
     def test_naive_datetime(self):
@@ -268,14 +268,11 @@
                 [event],
                 transform=lambda d: d)
 
-LegacyDatabaseTests = override_settings(USE_TZ=False)(LegacyDatabaseTests)
 
-
-#@override_settings(USE_TZ=True)
+@override_settings(USE_TZ=True)
 class NewDatabaseTests(BaseDateTimeTests):
 
     @requires_tz_support
-    @skipIf(sys.version_info < (2, 6), "this test requires Python >= 2.6")
     def test_naive_datetime(self):
         dt = datetime.datetime(2011, 9, 1, 13, 20, 30)
         with warnings.catch_warnings(record=True) as recorded:
@@ -289,7 +286,6 @@
         self.assertEqual(event.dt, dt.replace(tzinfo=EAT))
 
     @requires_tz_support
-    @skipIf(sys.version_info < (2, 6), "this test requires Python >= 2.6")
     def test_datetime_from_date(self):
         dt = datetime.date(2011, 9, 1)
         with warnings.catch_warnings(record=True) as recorded:
@@ -302,7 +298,6 @@
         self.assertEqual(event.dt, datetime.datetime(2011, 9, 1, tzinfo=EAT))
 
     @requires_tz_support
-    @skipIf(sys.version_info < (2, 6), "this test requires Python >= 2.6")
     @skipUnlessDBFeature('supports_microsecond_precision')
     def test_naive_datetime_with_microsecond(self):
         dt = datetime.datetime(2011, 9, 1, 13, 20, 30, 405060)
@@ -317,7 +312,6 @@
         self.assertEqual(event.dt, dt.replace(tzinfo=EAT))
 
     @requires_tz_support
-    @skipIf(sys.version_info < (2, 6), "this test requires Python >= 2.6")
     @skipIfDBFeature('supports_microsecond_precision')
     def test_naive_datetime_with_microsecond_unsupported(self):
         dt = datetime.datetime(2011, 9, 1, 13, 20, 30, 405060)
@@ -400,7 +394,6 @@
         self.assertEqual(Event.objects.filter(dt__range=(prev, next)).count(), 
1)
 
     @requires_tz_support
-    @skipIf(sys.version_info < (2, 6), "this test requires Python >= 2.6")
     def test_query_filter_with_naive_datetime(self):
         dt = datetime.datetime(2011, 9, 1, 12, 20, 30, tzinfo=EAT)
         Event.objects.create(dt=dt)
@@ -492,9 +485,7 @@
         e = MaybeEvent.objects.create()
         self.assertEqual(e.dt, None)
 
-NewDatabaseTests = override_settings(USE_TZ=True)(NewDatabaseTests)
 
-
 class SerializationTests(BaseDateTimeTests):
 
     # Backend-specific notes:
@@ -648,7 +639,7 @@
             obj = serializers.deserialize('yaml', data).next().object
             self.assertEqual(obj.dt.replace(tzinfo=UTC), dt)
 
-#@override_settings(DATETIME_FORMAT='c', USE_L10N=False, USE_TZ=True)
+@override_settings(DATETIME_FORMAT='c', USE_L10N=False, USE_TZ=True)
 class TemplateTests(BaseDateTimeTests):
 
     @requires_tz_support
@@ -887,9 +878,8 @@
         with timezone.override(ICT):
             self.assertEqual(tpl.render(Context({})), "+0700")
 
-TemplateTests = override_settings(DATETIME_FORMAT='c', USE_L10N=False, 
USE_TZ=True)(TemplateTests)
 
-#@override_settings(DATETIME_FORMAT='c', USE_L10N=False, USE_TZ=False)
+@override_settings(DATETIME_FORMAT='c', USE_L10N=False, USE_TZ=False)
 class LegacyFormsTests(BaseDateTimeTests):
 
     def test_form(self):
@@ -923,9 +913,8 @@
         e = Event.objects.get()
         self.assertEqual(e.dt, datetime.datetime(2011, 9, 1, 13, 20, 30))
 
-LegacyFormsTests = override_settings(DATETIME_FORMAT='c', USE_L10N=False, 
USE_TZ=False)(LegacyFormsTests)
 
-#@override_settings(DATETIME_FORMAT='c', USE_L10N=False, USE_TZ=True)
+@override_settings(DATETIME_FORMAT='c', USE_L10N=False, USE_TZ=True)
 class NewFormsTests(BaseDateTimeTests):
 
     @requires_tz_support
@@ -970,9 +959,8 @@
         e = Event.objects.get()
         self.assertEqual(e.dt, datetime.datetime(2011, 9, 1, 10, 20, 30, 
tzinfo=UTC))
 
-NewFormsTests = override_settings(DATETIME_FORMAT='c', USE_L10N=False, 
USE_TZ=True)(NewFormsTests)
 
-#@override_settings(DATETIME_FORMAT='c', USE_L10N=False, USE_TZ=True)
+@override_settings(DATETIME_FORMAT='c', USE_L10N=False, USE_TZ=True)
 class AdminTests(BaseDateTimeTests):
 
     urls = 'modeltests.timezones.urls'
@@ -1023,9 +1011,7 @@
             response = 
self.client.get(reverse('admin:timezones_timestamp_change', args=(t.pk,)))
         self.assertContains(response, t.created.astimezone(ICT).isoformat())
 
-AdminTests = override_settings(DATETIME_FORMAT='c', USE_L10N=False, 
USE_TZ=True)(AdminTests)
 
-
 class UtilitiesTests(BaseDateTimeTests):
 
     def test_make_aware(self):

Modified: django/trunk/tests/regressiontests/admin_views/tests.py
===================================================================
--- django/trunk/tests/regressiontests/admin_views/tests.py     2012-03-30 
08:02:08 UTC (rev 17828)
+++ django/trunk/tests/regressiontests/admin_views/tests.py     2012-03-30 
09:08:29 UTC (rev 17829)
@@ -3315,7 +3315,7 @@
 except ImportError:
     docutils = None
 
-#@unittest.skipUnless(docutils, "no docutils installed.")
+@unittest.skipUnless(docutils, "no docutils installed.")
 class AdminDocsTest(TestCase):
     urls = "regressiontests.admin_views.urls"
     fixtures = ['admin-views-users.xml']
@@ -3357,7 +3357,6 @@
         self.assertContains(response, '<h3 id="built_in-add">add</h3>', 
html=True)
         self.assertContains(response, '<li><a 
href="#built_in-add">add</a></li>', html=True)
 
-AdminDocsTest = unittest.skipUnless(docutils, "no docutils 
installed.")(AdminDocsTest)
 
 class ValidXHTMLTests(TestCase):
     urls = "regressiontests.admin_views.urls"

Modified: django/trunk/tests/regressiontests/cache/tests.py
===================================================================
--- django/trunk/tests/regressiontests/cache/tests.py   2012-03-30 08:02:08 UTC 
(rev 17828)
+++ django/trunk/tests/regressiontests/cache/tests.py   2012-03-30 09:08:29 UTC 
(rev 17829)
@@ -824,7 +824,9 @@
         self.assertTrue("Cache table 'test cache table' could not be created" 
in err.getvalue())
 
 
-DBCacheWithTimeZoneTests = override_settings(USE_TZ=True)(DBCacheTests)
+@override_settings(USE_TZ=True)
+class DBCacheWithTimeZoneTests(DBCacheTests):
+    pass
 
 
 class DBCacheRouter(object):
@@ -927,6 +929,9 @@
 # To check the memcached backend, the test settings file will
 # need to contain a cache backend setting that points at
 # your memcache server.
+@unittest.skipUnless(
+    
settings.CACHES[DEFAULT_CACHE_ALIAS]['BACKEND'].startswith('django.core.cache.backends.memcached.'),
+    "memcached not available")
 class MemcachedCacheTests(unittest.TestCase, BaseCacheTests):
     backend_name = 'django.core.cache.backends.memcached.MemcachedCache'
 
@@ -956,9 +961,7 @@
         # memcached limits key length to 250
         self.assertRaises(Exception, self.cache.set, 'a' * 251, 'value')
 
-MemcachedCacheTests = 
unittest.skipUnless(settings.CACHES[DEFAULT_CACHE_ALIAS]['BACKEND'].startswith('django.core.cache.backends.memcached.'),
 "memcached not available")(MemcachedCacheTests)
 
-
 class FileBasedCacheTests(unittest.TestCase, BaseCacheTests):
     """
     Specific test cases for the file-based cache.
@@ -1048,6 +1051,16 @@
         self.assertTrue(cache.closed)
 
 
+@override_settings(
+        CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix',
+        CACHE_MIDDLEWARE_SECONDS=1,
+        CACHES={
+            'default': {
+                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
+            },
+        },
+        USE_I18N=False,
+)
 class CacheUtils(TestCase):
     """TestCase for django.utils.cache functions."""
 
@@ -1144,27 +1157,28 @@
             parts = set(cc_delim_re.split(response['Cache-Control']))
             self.assertEqual(parts, expected_cc)
 
-CacheUtils = override_settings(
-        CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix',
-        CACHE_MIDDLEWARE_SECONDS=1,
+
+@override_settings(
         CACHES={
             'default': {
                 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
+                'KEY_PREFIX': 'cacheprefix',
             },
         },
-        USE_I18N=False,
-)(CacheUtils)
+)
+class PrefixedCacheUtils(CacheUtils):
+    pass
 
-PrefixedCacheUtils = override_settings(
+
+@override_settings(
+        CACHE_MIDDLEWARE_SECONDS=60,
+        CACHE_MIDDLEWARE_KEY_PREFIX='test',
         CACHES={
             'default': {
                 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
-                'KEY_PREFIX': 'cacheprefix',
             },
         },
-)(CacheUtils)
-
-
+)
 class CacheHEADTest(TestCase):
 
     def setUp(self):
@@ -1216,17 +1230,19 @@
         self.assertNotEqual(get_cache_data, None)
         self.assertEqual(test_content, get_cache_data.content)
 
-CacheHEADTest = override_settings(
-        CACHE_MIDDLEWARE_SECONDS=60,
-        CACHE_MIDDLEWARE_KEY_PREFIX='test',
+
+@override_settings(
+        CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix',
         CACHES={
             'default': {
                 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
             },
         },
-)(CacheHEADTest)
-
-
+        LANGUAGES=(
+            ('en', 'English'),
+            ('es', 'Spanish'),
+        ),
+)
 class CacheI18nTest(TestCase):
 
     def setUp(self):
@@ -1391,33 +1407,39 @@
         # reset the language
         translation.deactivate()
 
-CacheI18nTest = override_settings(
-        CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix',
-        CACHES={
-            'default': {
-                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
-            },
-        },
-        LANGUAGES=(
-            ('en', 'English'),
-            ('es', 'Spanish'),
-        ),
-)(CacheI18nTest)
 
-PrefixedCacheI18nTest = override_settings(
+@override_settings(
         CACHES={
             'default': {
                 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
                 'KEY_PREFIX': 'cacheprefix'
             },
         },
-)(CacheI18nTest)
+)
+class PrefixedCacheI18nTest(CacheI18nTest):
+    pass
 
 
 def hello_world_view(request, value):
     return HttpResponse('Hello World %s' % value)
 
 
+@override_settings(
+        CACHE_MIDDLEWARE_ALIAS='other',
+        CACHE_MIDDLEWARE_KEY_PREFIX='middlewareprefix',
+        CACHE_MIDDLEWARE_SECONDS=30,
+        CACHE_MIDDLEWARE_ANONYMOUS_ONLY=False,
+        CACHES={
+            'default': {
+                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
+            },
+            'other': {
+                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
+                'LOCATION': 'other',
+                'TIMEOUT': '1',
+            },
+        },
+)
 class CacheMiddlewareTest(TestCase):
 
     def setUp(self):
@@ -1635,24 +1657,17 @@
         response = other_with_timeout_view(request, '18')
         self.assertEqual(response.content, 'Hello World 18')
 
-CacheMiddlewareTest = override_settings(
-        CACHE_MIDDLEWARE_ALIAS='other',
-        CACHE_MIDDLEWARE_KEY_PREFIX='middlewareprefix',
-        CACHE_MIDDLEWARE_SECONDS=30,
-        CACHE_MIDDLEWARE_ANONYMOUS_ONLY=False,
+
+@override_settings(
+        CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix',
+        CACHE_MIDDLEWARE_SECONDS=1,
         CACHES={
             'default': {
                 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
             },
-            'other': {
-                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
-                'LOCATION': 'other',
-                'TIMEOUT': '1',
-            },
         },
-)(CacheMiddlewareTest)
-
-
+        USE_I18N=False,
+)
 class TestWithTemplateResponse(TestCase):
     """
     Tests various headers w/ TemplateResponse.
@@ -1740,18 +1755,7 @@
         response = response.render()
         self.assertTrue(response.has_header('ETag'))
 
-TestWithTemplateResponse = override_settings(
-        CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix',
-        CACHE_MIDDLEWARE_SECONDS=1,
-        CACHES={
-            'default': {
-                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
-            },
-        },
-        USE_I18N=False,
-)(TestWithTemplateResponse)
 
-
 class TestEtagWithAdmin(TestCase):
     # See https://code.djangoproject.com/ticket/16003
     urls = "regressiontests.admin_views.urls"

Modified: django/trunk/tests/regressiontests/forms/tests/media.py
===================================================================
--- django/trunk/tests/regressiontests/forms/tests/media.py     2012-03-30 
08:02:08 UTC (rev 17828)
+++ django/trunk/tests/regressiontests/forms/tests/media.py     2012-03-30 
09:08:29 UTC (rev 17829)
@@ -5,6 +5,10 @@
 from django.test.utils import override_settings
 
 
+@override_settings(
+    STATIC_URL=None,
+    MEDIA_URL='http://media.example.com/media/',
+)
 class FormsMediaTestCase(TestCase):
     """Tests for the media handling on widgets and forms"""
 
@@ -451,12 +455,11 @@
 <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" />
 <link href="/some/form/css" type="text/css" media="all" rel="stylesheet" />""")
 
-FormsMediaTestCase = override_settings(
-    STATIC_URL=None,
-    MEDIA_URL='http://media.example.com/media/',
-)(FormsMediaTestCase)
 
-
+@override_settings(
+    STATIC_URL='http://media.example.com/static/',
+    MEDIA_URL='http://media.example.com/media/',
+)
 class StaticFormsMediaTestCase(TestCase):
     """Tests for the media handling on widgets and forms"""
 
@@ -902,9 +905,3 @@
 <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
 <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" />
 <link href="/some/form/css" type="text/css" media="all" rel="stylesheet" />""")
-
-
-StaticFormsMediaTestCase = override_settings(
-    STATIC_URL='http://media.example.com/static/',
-    MEDIA_URL='http://media.example.com/media/',
-)(StaticFormsMediaTestCase)

Modified: django/trunk/tests/regressiontests/i18n/contenttypes/tests.py
===================================================================
--- django/trunk/tests/regressiontests/i18n/contenttypes/tests.py       
2012-03-30 08:02:08 UTC (rev 17828)
+++ django/trunk/tests/regressiontests/i18n/contenttypes/tests.py       
2012-03-30 09:08:29 UTC (rev 17829)
@@ -8,6 +8,17 @@
 from django.utils import translation
 
 
+@override_settings(
+    USE_I18N=True,
+    LOCALE_PATHS=(
+        os.path.join(os.path.dirname(__file__), 'locale'),
+    ),
+    LANGUAGE_CODE='en',
+    LANGUAGES=(
+        ('en', 'English'),
+        ('fr', 'French'),
+    ),
+)
 class ContentTypeTests(TestCase):
     def test_verbose_name(self):
         company_type = ContentType.objects.get(app_label='i18n', 
model='company')
@@ -20,15 +31,3 @@
         company_type = ContentType.objects.get(app_label='i18n', 
model='company')
         company_type.name = 'Other'
         self.assertEqual(unicode(company_type), 'Other')
-
-ContentTypeTests = override_settings(
-    USE_I18N=True,
-    LOCALE_PATHS=(
-        os.path.join(os.path.dirname(__file__), 'locale'),
-    ),
-    LANGUAGE_CODE='en',
-    LANGUAGES=(
-        ('en', 'English'),
-        ('fr', 'French'),
-    ),
-)(ContentTypeTests)

Modified: django/trunk/tests/regressiontests/i18n/patterns/tests.py
===================================================================
--- django/trunk/tests/regressiontests/i18n/patterns/tests.py   2012-03-30 
08:02:08 UTC (rev 17828)
+++ django/trunk/tests/regressiontests/i18n/patterns/tests.py   2012-03-30 
09:08:29 UTC (rev 17829)
@@ -9,21 +9,7 @@
 from django.utils import translation
 
 
-class URLTestCaseBase(TestCase):
-    """
-    TestCase base-class for the URL tests.
-    """
-    urls = 'regressiontests.i18n.patterns.urls.default'
-
-    def setUp(self):
-        # Make sure the cache is empty before we are doing our tests.
-        clear_url_caches()
-
-    def tearDown(self):
-        # Make sure we will leave an empty cache for other testcases.
-        clear_url_caches()
-
-URLTestCaseBase = override_settings(
+@override_settings(
     USE_I18N=True,
     LOCALE_PATHS=(
         os.path.join(os.path.dirname(__file__), 'locale'),
@@ -41,9 +27,22 @@
         'django.middleware.locale.LocaleMiddleware',
         'django.middleware.common.CommonMiddleware',
     ),
-)(URLTestCaseBase)
+)
+class URLTestCaseBase(TestCase):
+    """
+    TestCase base-class for the URL tests.
+    """
+    urls = 'regressiontests.i18n.patterns.urls.default'
 
+    def setUp(self):
+        # Make sure the cache is empty before we are doing our tests.
+        clear_url_caches()
 
+    def tearDown(self):
+        # Make sure we will leave an empty cache for other testcases.
+        clear_url_caches()
+
+
 class URLPrefixTests(URLTestCaseBase):
     """
     Tests if the `i18n_patterns` is adding the prefix correctly.

Modified: django/trunk/tests/regressiontests/middleware/tests.py
===================================================================
--- django/trunk/tests/regressiontests/middleware/tests.py      2012-03-30 
08:02:08 UTC (rev 17828)
+++ django/trunk/tests/regressiontests/middleware/tests.py      2012-03-30 
09:08:29 UTC (rev 17829)
@@ -584,6 +584,7 @@
         self.assertEqual(r.get('Content-Encoding'), None)
 
 
+@override_settings(USE_ETAGS=True)
 class ETagGZipMiddlewareTest(TestCase):
     """
     Tests if the ETag middleware behaves correctly with GZip middleware.
@@ -610,6 +611,3 @@
         nogzip_etag = response.get('ETag')
 
         self.assertNotEqual(gzip_etag, nogzip_etag)
-ETagGZipMiddlewareTest = override_settings(
-    USE_ETAGS=True,
-)(ETagGZipMiddlewareTest)

Modified: django/trunk/tests/regressiontests/settings_tests/tests.py
===================================================================
--- django/trunk/tests/regressiontests/settings_tests/tests.py  2012-03-30 
08:02:08 UTC (rev 17828)
+++ django/trunk/tests/regressiontests/settings_tests/tests.py  2012-03-30 
09:08:29 UTC (rev 17829)
@@ -6,7 +6,7 @@
 from django.test.utils import override_settings
 
 
-# @override_settings(TEST='override')
+@override_settings(TEST='override')
 class FullyDecoratedTranTestCase(TransactionTestCase):
 
     def test_override(self):
@@ -22,9 +22,8 @@
     def test_decorated_testcase_module(self):
         self.assertEquals(FullyDecoratedTranTestCase.__module__, __name__)
 
-FullyDecoratedTranTestCase = 
override_settings(TEST='override')(FullyDecoratedTranTestCase)
 
-# @override_settings(TEST='override')
+@override_settings(TEST='override')
 class FullyDecoratedTestCase(TestCase):
 
     def test_override(self):
@@ -34,9 +33,7 @@
     def test_method_override(self):
         self.assertEqual(settings.TEST, 'override2')
 
-FullyDecoratedTestCase = 
override_settings(TEST='override')(FullyDecoratedTestCase)
 
-
 class ClassDecoratedTestCaseSuper(TestCase):
     """
     Dummy class for testing max recursion error in child class call to
@@ -47,6 +44,7 @@
         pass
 
 
+@override_settings(TEST='override')
 class ClassDecoratedTestCase(ClassDecoratedTestCaseSuper):
     def test_override(self):
         self.assertEqual(settings.TEST, 'override')
@@ -66,7 +64,6 @@
         except RuntimeError, e:
             self.fail()
 
-ClassDecoratedTestCase = 
override_settings(TEST='override')(ClassDecoratedTestCase)
 
 class SettingGetter(object):
     def __init__(self):

Modified: django/trunk/tests/regressiontests/staticfiles_tests/tests.py
===================================================================
--- django/trunk/tests/regressiontests/staticfiles_tests/tests.py       
2012-03-30 08:02:08 UTC (rev 17828)
+++ django/trunk/tests/regressiontests/staticfiles_tests/tests.py       
2012-03-30 09:08:29 UTC (rev 17829)
@@ -98,9 +98,9 @@
         self.assertRaises(exc, self.assertStaticRenders, path, result, 
**kwargs)
 
 
+@override_settings(**TEST_SETTINGS)
 class StaticFilesTestCase(BaseStaticFilesTestCase, TestCase):
     pass
-StaticFilesTestCase = override_settings(**TEST_SETTINGS)(StaticFilesTestCase)
 
 
 class BaseCollectionTestCase(BaseStaticFilesTestCase):
@@ -343,17 +343,21 @@
         self.assertFileContains('file2.txt', 'duplicate of file2.txt')
 
 
+@override_settings(
+    
STATICFILES_STORAGE='regressiontests.staticfiles_tests.storage.DummyStorage',
+)
 class TestCollectionNonLocalStorage(CollectionTestCase, TestNoFilesCreated):
     """
     Tests for #15035
     """
     pass
 
-TestCollectionNonLocalStorage = override_settings(
-    
STATICFILES_STORAGE='regressiontests.staticfiles_tests.storage.DummyStorage',
-)(TestCollectionNonLocalStorage)
 
-
+# we set DEBUG to False here since the template tag wouldn't work otherwise
+@override_settings(**dict(TEST_SETTINGS,
+    
STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage',
+    DEBUG=False,
+))
 class TestCollectionCachedStorage(BaseCollectionTestCase,
         BaseStaticFilesTestCase, TestCase):
     """
@@ -515,12 +519,6 @@
         self.assertEqual(cache_key, 
'staticfiles:e95bbc36387084582df2a70750d7b351')
 
 
-# we set DEBUG to False here since the template tag wouldn't work otherwise
-TestCollectionCachedStorage = override_settings(**dict(TEST_SETTINGS,
-    
STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage',
-    DEBUG=False,
-))(TestCollectionCachedStorage)
-
 if sys.platform != 'win32':
 
     class TestCollectionLinks(CollectionTestCase, TestDefaults):

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to