summaryrefslogtreecommitdiff
path: root/django/contrib/auth/tests/test_forms.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2014-12-17 22:10:57 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2014-12-28 17:02:30 +0100
commitcf0fd65ed42d5d4f0585da413db4b1cf7c6b0d1a (patch)
tree3f4f652525adf16178018e4ce0c7eddeb0f61360 /django/contrib/auth/tests/test_forms.py
parentd3a982556d655adcf4ba331d2def685d8249170f (diff)
Deprecated TEMPLATE_LOADERS.
Diffstat (limited to 'django/contrib/auth/tests/test_forms.py')
-rw-r--r--django/contrib/auth/tests/test_forms.py59
1 files changed, 27 insertions, 32 deletions
diff --git a/django/contrib/auth/tests/test_forms.py b/django/contrib/auth/tests/test_forms.py
index 0c13e8af74..93ce9ad073 100644
--- a/django/contrib/auth/tests/test_forms.py
+++ b/django/contrib/auth/tests/test_forms.py
@@ -1,6 +1,5 @@
from __future__ import unicode_literals
-import os
import re
from django import forms
@@ -8,17 +7,18 @@ from django.contrib.auth.models import User
from django.contrib.auth.forms import (UserCreationForm, AuthenticationForm,
PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm,
ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget)
-from django.contrib.auth.tests.utils import skipIfCustomUser
from django.core import mail
from django.core.mail import EmailMultiAlternatives
from django.forms.fields import Field, CharField
from django.test import TestCase, override_settings
from django.utils.encoding import force_text
-from django.utils._os import upath
from django.utils import translation
from django.utils.text import capfirst
from django.utils.translation import ugettext as _
+from .settings import AUTH_TEMPLATES
+from .utils import skipIfCustomUser
+
@skipIfCustomUser
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
@@ -360,10 +360,7 @@ class UserChangeFormTest(TestCase):
@skipIfCustomUser
@override_settings(
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
- TEMPLATE_LOADERS=('django.template.loaders.filesystem.Loader',),
- TEMPLATE_DIRS=(
- os.path.join(os.path.dirname(upath(__file__)), 'templates'),
- ),
+ TEMPLATES=AUTH_TEMPLATES,
USE_TZ=False,
)
class PasswordResetFormTest(TestCase):
@@ -416,33 +413,31 @@ class PasswordResetFormTest(TestCase):
self.assertEqual(mail.outbox[0].subject, 'Custom password reset on example.com')
def test_custom_email_constructor(self):
- template_path = os.path.join(os.path.dirname(__file__), 'templates')
- with self.settings(TEMPLATE_DIRS=(template_path,)):
- data = {'email': 'testclient@example.com'}
+ data = {'email': 'testclient@example.com'}
- class CustomEmailPasswordResetForm(PasswordResetForm):
- def send_mail(self, subject_template_name, email_template_name,
- context, from_email, to_email,
- html_email_template_name=None):
- EmailMultiAlternatives(
- "Forgot your password?",
- "Sorry to hear you forgot your password.",
- None, [to_email],
- ['site_monitor@example.com'],
- headers={'Reply-To': 'webmaster@example.com'},
- alternatives=[("Really sorry to hear you forgot your password.",
- "text/html")]).send()
+ class CustomEmailPasswordResetForm(PasswordResetForm):
+ def send_mail(self, subject_template_name, email_template_name,
+ context, from_email, to_email,
+ html_email_template_name=None):
+ EmailMultiAlternatives(
+ "Forgot your password?",
+ "Sorry to hear you forgot your password.",
+ None, [to_email],
+ ['site_monitor@example.com'],
+ headers={'Reply-To': 'webmaster@example.com'},
+ alternatives=[("Really sorry to hear you forgot your password.",
+ "text/html")]).send()
- form = CustomEmailPasswordResetForm(data)
- self.assertTrue(form.is_valid())
- # Since we're not providing a request object, we must provide a
- # domain_override to prevent the save operation from failing in the
- # potential case where contrib.sites is not installed. Refs #16412.
- form.save(domain_override='example.com')
- self.assertEqual(len(mail.outbox), 1)
- self.assertEqual(mail.outbox[0].subject, 'Forgot your password?')
- self.assertEqual(mail.outbox[0].bcc, ['site_monitor@example.com'])
- self.assertEqual(mail.outbox[0].content_subtype, "plain")
+ form = CustomEmailPasswordResetForm(data)
+ self.assertTrue(form.is_valid())
+ # Since we're not providing a request object, we must provide a
+ # domain_override to prevent the save operation from failing in the
+ # potential case where contrib.sites is not installed. Refs #16412.
+ form.save(domain_override='example.com')
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual(mail.outbox[0].subject, 'Forgot your password?')
+ self.assertEqual(mail.outbox[0].bcc, ['site_monitor@example.com'])
+ self.assertEqual(mail.outbox[0].content_subtype, "plain")
def test_preserve_username_case(self):
"""