Commit eb163f37 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

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
parent 9383a276
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -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)
+6 −13
Original line number Diff line number Diff line
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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)

+4 −8
Original line number Diff line number Diff line
@@ -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):

+1 −2
Original line number Diff line number Diff line
@@ -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)
Loading