diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-03-30 09:08:29 +0000 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-03-30 09:08:29 +0000 |
| commit | eb163f37cb62268443d592f8ce08bd8a0ab9631d (patch) | |
| tree | a373546137a3833d476b207d6490bd39c1e51a81 /django | |
| parent | 9383a2761c67d588378f3679cc6c8ea3651a73c8 (diff) | |
Use the class decorator syntax available in Python >= 2.6. Refs #17965.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17829 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/auth/tests/context_processors.py | 13 | ||||
| -rw-r--r-- | django/contrib/auth/tests/forms.py | 19 | ||||
| -rw-r--r-- | django/contrib/auth/tests/hashers.py | 2 | ||||
| -rw-r--r-- | django/contrib/auth/tests/models.py | 12 | ||||
| -rw-r--r-- | django/contrib/auth/tests/signals.py | 3 | ||||
| -rw-r--r-- | django/contrib/auth/tests/views.py | 3 | ||||
| -rw-r--r-- | django/contrib/messages/tests/cookie.py | 4 | ||||
| -rw-r--r-- | django/contrib/sessions/tests.py | 8 | ||||
| -rw-r--r-- | django/contrib/sitemaps/tests/https.py | 5 |
9 files changed, 28 insertions, 41 deletions
diff --git a/django/contrib/auth/tests/context_processors.py b/django/contrib/auth/tests/context_processors.py index dcd50fc6cc..bba2046b31 100644 --- a/django/contrib/auth/tests/context_processors.py +++ b/django/contrib/auth/tests/context_processors.py @@ -8,6 +8,12 @@ from django.test import TestCase 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 @@ class AuthContextProcessorTests(TestCase): # 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) diff --git a/django/contrib/auth/tests/forms.py b/django/contrib/auth/tests/forms.py index 27908282eb..3ad2afd592 100644 --- a/django/contrib/auth/tests/forms.py +++ b/django/contrib/auth/tests/forms.py @@ -11,6 +11,7 @@ from django.utils import translation from django.utils.translation import ugettext as _ +@override_settings(USE_TZ=False) class UserCreationFormTest(TestCase): fixtures = ['authtestdata.json'] @@ -75,9 +76,8 @@ class UserCreationFormTest(TestCase): u = form.save() self.assertEqual(repr(u), '<User: jsmith@example.com>') -UserCreationFormTest = override_settings(USE_TZ=False)(UserCreationFormTest) - +@override_settings(USE_TZ=False) class AuthenticationFormTest(TestCase): fixtures = ['authtestdata.json'] @@ -128,9 +128,8 @@ class AuthenticationFormTest(TestCase): 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 @@ class SetPasswordFormTest(TestCase): 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 @@ class PasswordChangeFormTest(TestCase): 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 @@ class UserChangeFormTest(TestCase): 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 @@ class PasswordResetFormTest(TestCase): 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) diff --git a/django/contrib/auth/tests/hashers.py b/django/contrib/auth/tests/hashers.py index 865085a194..8a11511688 100644 --- a/django/contrib/auth/tests/hashers.py +++ b/django/contrib/auth/tests/hashers.py @@ -4,7 +4,6 @@ from django.contrib.auth.hashers import (is_password_usable, 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 @@ except ImportError: class TestUtilsHashPass(unittest.TestCase): + def setUp(self): load_hashers(password_hashers=default_hashers) diff --git a/django/contrib/auth/tests/models.py b/django/contrib/auth/tests/models.py index 5d0e4f1443..324f433df6 100644 --- a/django/contrib/auth/tests/models.py +++ b/django/contrib/auth/tests/models.py @@ -5,6 +5,7 @@ from django.contrib.auth.models import (Group, User, SiteProfileNotAvailable, UserManager) +@override_settings(USE_TZ=False) class ProfileTestCase(TestCase): fixtures = ['authtestdata.json'] @@ -38,9 +39,8 @@ class ProfileTestCase(TestCase): 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 @@ class NaturalKeysTestCase(TestCase): 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 @@ class LoadDataWithoutNaturalKeysTestCase(TestCase): 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,8 +73,6 @@ class LoadDataWithNaturalKeysTestCase(TestCase): group = Group.objects.get(name='my_group') self.assertEquals(group, user.groups.get()) -LoadDataWithNaturalKeysTestCase = override_settings(USE_TZ=False)(LoadDataWithNaturalKeysTestCase) - class UserManagerTestCase(TestCase): diff --git a/django/contrib/auth/tests/signals.py b/django/contrib/auth/tests/signals.py index fc308c582d..7730ab0952 100644 --- a/django/contrib/auth/tests/signals.py +++ b/django/contrib/auth/tests/signals.py @@ -3,6 +3,7 @@ from django.test.utils import override_settings 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 @@ class SignalTestCase(TestCase): 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) diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/views.py index 37045cd898..ac1e225a3b 100644 --- a/django/contrib/auth/tests/views.py +++ b/django/contrib/auth/tests/views.py @@ -18,6 +18,7 @@ from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm, SetPasswordForm, PasswordResetForm) +@override_settings(USE_TZ=False) class AuthViewsTestCase(TestCase): """ Helper base class for all the follow test cases. @@ -52,8 +53,6 @@ class AuthViewsTestCase(TestCase): 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' diff --git a/django/contrib/messages/tests/cookie.py b/django/contrib/messages/tests/cookie.py index 30aa6b53a6..3cba692286 100644 --- a/django/contrib/messages/tests/cookie.py +++ b/django/contrib/messages/tests/cookie.py @@ -38,6 +38,7 @@ def stored_cookie_messages_count(storage, response): return len(data) +@override_settings(SESSION_COOKIE_DOMAIN='.lawrence.com') class CookieTest(BaseTest): storage_class = CookieStorage @@ -130,6 +131,3 @@ 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) diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py index 107a7bcd80..89bcce84ff 100644 --- a/django/contrib/sessions/tests.py +++ b/django/contrib/sessions/tests.py @@ -287,7 +287,9 @@ class DatabaseSessionTests(SessionTestsMixin, TestCase): 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 @@ class CacheDBSessionTests(SessionTestsMixin, TestCase): 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 diff --git a/django/contrib/sitemaps/tests/https.py b/django/contrib/sitemaps/tests/https.py index b590bf2215..d4f9053fc8 100644 --- a/django/contrib/sitemaps/tests/https.py +++ b/django/contrib/sitemaps/tests/https.py @@ -26,7 +26,8 @@ class HTTPSSitemapTests(SitemapTestsBase): </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 @@ class HTTPSDetectionSitemapTests(SitemapTestsBase): <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) |
