Fixed #17940 -- Enforced USE_TZ = False in contrib apps tests that use fixtures containing datetimes.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17770 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Aymeric Augustin 2012-03-20 20:51:16 +00:00
parent 163c8def82
commit ed27ae071f
5 changed files with 35 additions and 5 deletions

View File

@ -99,5 +99,6 @@ class AuthContextProcessorTests(TestCase):
AuthContextProcessorTests = override_settings(
TEMPLATE_DIRS=(
os.path.join(os.path.dirname(__file__), 'templates'),
)
),
USE_TZ=False, # required for loading the fixture
)(AuthContextProcessorTests)

View File

@ -1,10 +1,12 @@
from __future__ import with_statement
import os
from django.contrib.auth.models import User
from django.contrib.auth.forms import (UserCreationForm, AuthenticationForm,
PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm)
from django.core import mail
from django.forms.fields import Field, EmailField
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm
from django.test import TestCase
from django.test.utils import override_settings
from django.utils.encoding import force_unicode
from django.utils import translation
@ -74,6 +76,8 @@ class UserCreationFormTest(TestCase):
u = form.save()
self.assertEqual(repr(u), '<User: jsmith@example.com>')
UserCreationFormTest = override_settings(USE_TZ=False)(UserCreationFormTest)
class AuthenticationFormTest(TestCase):
@ -125,6 +129,8 @@ class AuthenticationFormTest(TestCase):
self.assertTrue(form.is_valid())
self.assertEqual(form.non_field_errors(), [])
AuthenticationFormTest = override_settings(USE_TZ=False)(AuthenticationFormTest)
class SetPasswordFormTest(TestCase):
@ -151,6 +157,8 @@ class SetPasswordFormTest(TestCase):
form = SetPasswordForm(user, data)
self.assertTrue(form.is_valid())
SetPasswordFormTest = override_settings(USE_TZ=False)(SetPasswordFormTest)
class PasswordChangeFormTest(TestCase):
@ -198,6 +206,8 @@ class PasswordChangeFormTest(TestCase):
self.assertEqual(PasswordChangeForm(user, {}).fields.keys(),
['old_password', 'new_password1', 'new_password2'])
PasswordChangeFormTest = override_settings(USE_TZ=False)(PasswordChangeFormTest)
class UserChangeFormTest(TestCase):
@ -226,6 +236,8 @@ class UserChangeFormTest(TestCase):
# Just check we can create it
form = MyUserForm({})
UserChangeFormTest = override_settings(USE_TZ=False)(UserChangeFormTest)
class PasswordResetFormTest(TestCase):
@ -304,3 +316,5 @@ 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)

View File

@ -1,6 +1,7 @@
from django.conf import settings
from django.test import TestCase
from django.contrib.auth.models import (Group, User,
from django.test.utils import override_settings
svn from django.contrib.auth.models import (Group, User,
SiteProfileNotAvailable, UserManager)
@ -37,6 +38,8 @@ class ProfileTestCase(TestCase):
settings.AUTH_PROFILE_MODULE = 'foo.bar'
self.assertRaises(SiteProfileNotAvailable, user.get_profile)
ProfileTestCase = override_settings(USE_TZ=False)(ProfileTestCase)
class NaturalKeysTestCase(TestCase):
fixtures = ['authtestdata.json']
@ -50,6 +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)
class LoadDataWithoutNaturalKeysTestCase(TestCase):
fixtures = ['regular.json']
@ -59,6 +64,8 @@ class LoadDataWithoutNaturalKeysTestCase(TestCase):
group = Group.objects.get(name='my_group')
self.assertEquals(group, user.groups.get())
LoadDataWithoutNaturalKeysTestCase = override_settings(USE_TZ=False)(LoadDataWithoutNaturalKeysTestCase)
class LoadDataWithNaturalKeysTestCase(TestCase):
fixtures = ['natural.json']
@ -68,6 +75,8 @@ 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):

View File

@ -1,4 +1,5 @@
from django.test import TestCase
from django.test.utils import override_settings
from django.contrib.auth import signals
@ -45,3 +46,5 @@ 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)

View File

@ -12,6 +12,7 @@ from django.http import QueryDict
from django.utils.encoding import force_unicode
from django.utils.html import escape
from django.test import TestCase
from django.test.utils import override_settings
from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME
from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm,
@ -52,6 +53,8 @@ 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'