Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #17940 -- Enforced USE_TZ = False in contrib apps tests that us…

…e fixtures containing datetimes.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17770 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ed27ae071f5a3c6515cd205333aa3dee58714751 1 parent 163c8de
@aaugustin aaugustin authored
View
5 django/contrib/auth/tests/context_processors.py
@@ -97,7 +97,8 @@ def test_user_attrs(self):
self.assertEqual(user, response.context['user'])
AuthContextProcessorTests = override_settings(
- TEMPLATE_DIRS = (
+ TEMPLATE_DIRS=(
os.path.join(os.path.dirname(__file__), 'templates'),
- )
+ ),
+ USE_TZ=False, # required for loading the fixture
)(AuthContextProcessorTests)
View
18 django/contrib/auth/tests/forms.py
@@ -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 @@ def test_success(self):
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 @@ def test_success(self):
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 @@ def test_success(self):
form = SetPasswordForm(user, data)
self.assertTrue(form.is_valid())
+SetPasswordFormTest = override_settings(USE_TZ=False)(SetPasswordFormTest)
+
class PasswordChangeFormTest(TestCase):
@@ -198,6 +206,8 @@ def test_field_order(self):
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 Meta(UserChangeForm.Meta):
# Just check we can create it
form = MyUserForm({})
+UserChangeFormTest = override_settings(USE_TZ=False)(UserChangeFormTest)
+
class PasswordResetFormTest(TestCase):
@@ -304,3 +316,5 @@ def test_unusable_password(self):
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
11 django/contrib/auth/tests/models.py
@@ -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 @@ def test_site_profile_not_available(self):
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 @@ def test_group_natural_key(self):
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 @@ def test_user_is_created_and_added_to_group(self):
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 @@ def test_user_is_created_and_added_to_group(self):
group = Group.objects.get(name='my_group')
self.assertEquals(group, user.groups.get())
+LoadDataWithNaturalKeysTestCase = override_settings(USE_TZ=False)(LoadDataWithNaturalKeysTestCase)
+
class UserManagerTestCase(TestCase):
View
3  django/contrib/auth/tests/signals.py
@@ -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 @@ def test_logout(self):
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
3  django/contrib/auth/tests/views.py
@@ -12,6 +12,7 @@
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 @@ def login(self, password='password'):
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'

0 comments on commit ed27ae0

Please sign in to comment.
Something went wrong with that request. Please try again.