Author: aaugustin
Date: 2012-03-20 13:51:16 -0700 (Tue, 20 Mar 2012)
New Revision: 17770
Modified:
django/trunk/django/contrib/auth/tests/context_processors.py
django/trunk/django/contrib/auth/tests/forms.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
Log:
Fixed #17940 -- Enforced USE_TZ = False in contrib apps tests that use fixtures
containing datetimes.
Modified: django/trunk/django/contrib/auth/tests/context_processors.py
===================================================================
--- django/trunk/django/contrib/auth/tests/context_processors.py
2012-03-19 21:02:35 UTC (rev 17769)
+++ django/trunk/django/contrib/auth/tests/context_processors.py
2012-03-20 20:51:16 UTC (rev 17770)
@@ -97,7 +97,8 @@
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)
Modified: django/trunk/django/contrib/auth/tests/forms.py
===================================================================
--- django/trunk/django/contrib/auth/tests/forms.py 2012-03-19 21:02:35 UTC
(rev 17769)
+++ django/trunk/django/contrib/auth/tests/forms.py 2012-03-20 20:51:16 UTC
(rev 17770)
@@ -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,7 +76,9 @@
u = form.save()
self.assertEqual(repr(u), '<User: [email protected]>')
+UserCreationFormTest = override_settings(USE_TZ=False)(UserCreationFormTest)
+
class AuthenticationFormTest(TestCase):
fixtures = ['authtestdata.json']
@@ -125,7 +129,9 @@
self.assertTrue(form.is_valid())
self.assertEqual(form.non_field_errors(), [])
+AuthenticationFormTest =
override_settings(USE_TZ=False)(AuthenticationFormTest)
+
class SetPasswordFormTest(TestCase):
fixtures = ['authtestdata.json']
@@ -151,7 +157,9 @@
form = SetPasswordForm(user, data)
self.assertTrue(form.is_valid())
+SetPasswordFormTest = override_settings(USE_TZ=False)(SetPasswordFormTest)
+
class PasswordChangeFormTest(TestCase):
fixtures = ['authtestdata.json']
@@ -198,7 +206,9 @@
self.assertEqual(PasswordChangeForm(user, {}).fields.keys(),
['old_password', 'new_password1', 'new_password2'])
+PasswordChangeFormTest =
override_settings(USE_TZ=False)(PasswordChangeFormTest)
+
class UserChangeFormTest(TestCase):
fixtures = ['authtestdata.json']
@@ -226,7 +236,9 @@
# Just check we can create it
form = MyUserForm({})
+UserChangeFormTest = override_settings(USE_TZ=False)(UserChangeFormTest)
+
class PasswordResetFormTest(TestCase):
fixtures = ['authtestdata.json']
@@ -304,3 +316,5 @@
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/models.py
===================================================================
--- django/trunk/django/contrib/auth/tests/models.py 2012-03-19 21:02:35 UTC
(rev 17769)
+++ django/trunk/django/contrib/auth/tests/models.py 2012-03-20 20:51:16 UTC
(rev 17770)
@@ -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,7 +38,9 @@
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,7 +53,9 @@
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,7 +64,9 @@
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,7 +75,9 @@
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-19 21:02:35 UTC
(rev 17769)
+++ django/trunk/django/contrib/auth/tests/signals.py 2012-03-20 20:51:16 UTC
(rev 17770)
@@ -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 @@
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-19 21:02:35 UTC
(rev 17769)
+++ django/trunk/django/contrib/auth/tests/views.py 2012-03-20 20:51:16 UTC
(rev 17770)
@@ -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,7 +53,9 @@
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'
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.