Fixed #17899 -- Rewrote [Ee]-mail to [Ee]mail

This commit is contained in:
Adrien Lemaire 2012-09-26 14:14:51 +02:00 committed by Claude Paroz
parent 70a0de37d1
commit 2c8267bf3d
24 changed files with 51 additions and 51 deletions

View File

@ -144,7 +144,7 @@ DEFAULT_CHARSET = 'utf-8'
# Encoding of files read from disk (template and initial SQL files). # Encoding of files read from disk (template and initial SQL files).
FILE_CHARSET = 'utf-8' FILE_CHARSET = 'utf-8'
# E-mail address that error messages come from. # Email address that error messages come from.
SERVER_EMAIL = 'root@localhost' SERVER_EMAIL = 'root@localhost'
# Whether to send broken-link emails. # Whether to send broken-link emails.

View File

@ -12,6 +12,6 @@
{% block content %} {% block content %}
<h1>{% trans 'Server Error <em>(500)</em>' %}</h1> <h1>{% trans 'Server Error <em>(500)</em>' %}</h1>
<p>{% trans "There's been an error. It's been reported to the site administrators via e-mail and should be fixed shortly. Thanks for your patience." %}</p> <p>{% trans "There's been an error. It's been reported to the site administrators via email and should be fixed shortly. Thanks for your patience." %}</p>
{% endblock %} {% endblock %}

View File

@ -14,6 +14,6 @@
<h1>{% trans 'Password reset successful' %}</h1> <h1>{% trans 'Password reset successful' %}</h1>
<p>{% trans "We've e-mailed you instructions for setting your password to the e-mail address you submitted. You should be receiving it shortly." %}</p> <p>{% trans "We've emailed you instructions for setting your password to the email address you submitted. You should be receiving it shortly." %}</p>
{% endblock %} {% endblock %}

View File

@ -1,5 +1,5 @@
{% load i18n %}{% autoescape off %} {% load i18n %}{% autoescape off %}
{% blocktrans %}You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %} {% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %} {% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %} {% block reset_link %}

View File

@ -14,11 +14,11 @@
<h1>{% trans "Password reset" %}</h1> <h1>{% trans "Password reset" %}</h1>
<p>{% trans "Forgotten your password? Enter your e-mail address below, and we'll e-mail instructions for setting a new one." %}</p> <p>{% trans "Forgotten your password? Enter your email address below, and we'll email instructions for setting a new one." %}</p>
<form action="" method="post">{% csrf_token %} <form action="" method="post">{% csrf_token %}
{{ form.email.errors }} {{ form.email.errors }}
<p><label for="id_email">{% trans 'E-mail address:' %}</label> {{ form.email }} <input type="submit" value="{% trans 'Reset my password' %}" /></p> <p><label for="id_email">{% trans 'Email address:' %}</label> {{ form.email }} <input type="submit" value="{% trans 'Reset my password' %}" /></p>
</form> </form>
{% endblock %} {% endblock %}

View File

@ -193,12 +193,12 @@ class AuthenticationForm(forms.Form):
class PasswordResetForm(forms.Form): class PasswordResetForm(forms.Form):
error_messages = { error_messages = {
'unknown': _("That e-mail address doesn't have an associated " 'unknown': _("That email address doesn't have an associated "
"user account. Are you sure you've registered?"), "user account. Are you sure you've registered?"),
'unusable': _("The user account associated with this e-mail " 'unusable': _("The user account associated with this email "
"address cannot reset the password."), "address cannot reset the password."),
} }
email = forms.EmailField(label=_("E-mail"), max_length=75) email = forms.EmailField(label=_("Email"), max_length=75)
def clean_email(self): def clean_email(self):
""" """

View File

@ -344,4 +344,4 @@ class PasswordResetFormTest(TestCase):
form = PasswordResetForm(data) form = PasswordResetForm(data)
self.assertFalse(form.is_valid()) self.assertFalse(form.is_valid())
self.assertEqual(form["email"].errors, self.assertEqual(form["email"].errors,
[_("The user account associated with this e-mail address cannot reset the password.")]) [_("The user account associated with this email address cannot reset the password.")])

View File

@ -1 +1 @@
E-mail sent Email sent

View File

@ -101,7 +101,7 @@ email_re = re.compile(
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"' r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"'
r')@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$)' # domain r')@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$)' # domain
r'|\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$', re.IGNORECASE) # literal form, ipv4 address (SMTP 4.1.3) r'|\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$', re.IGNORECASE) # literal form, ipv4 address (SMTP 4.1.3)
validate_email = EmailValidator(email_re, _('Enter a valid e-mail address.'), 'invalid') validate_email = EmailValidator(email_re, _('Enter a valid email address.'), 'invalid')
slug_re = re.compile(r'^[-a-zA-Z0-9_]+$') slug_re = re.compile(r'^[-a-zA-Z0-9_]+$')
validate_slug = RegexValidator(slug_re, _("Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens."), 'invalid') validate_slug = RegexValidator(slug_re, _("Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens."), 'invalid')

View File

@ -905,7 +905,7 @@ class DecimalField(Field):
class EmailField(CharField): class EmailField(CharField):
default_validators = [validators.validate_email] default_validators = [validators.validate_email]
description = _("E-mail address") description = _("Email address")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
# max_length should be overridden to 254 characters to be fully # max_length should be overridden to 254 characters to be fully

View File

@ -461,7 +461,7 @@ class RegexField(CharField):
class EmailField(CharField): class EmailField(CharField):
default_error_messages = { default_error_messages = {
'invalid': _('Enter a valid e-mail address.'), 'invalid': _('Enter a valid email address.'),
} }
default_validators = [validators.validate_email] default_validators = [validators.validate_email]

View File

@ -241,7 +241,7 @@ applications:
* :doc:`Authentication <topics/auth>` * :doc:`Authentication <topics/auth>`
* :doc:`Caching <topics/cache>` * :doc:`Caching <topics/cache>`
* :doc:`Logging <topics/logging>` * :doc:`Logging <topics/logging>`
* :doc:`Sending e-mails <topics/email>` * :doc:`Sending emails <topics/email>`
* :doc:`Syndication feeds (RSS/Atom) <ref/contrib/syndication>` * :doc:`Syndication feeds (RSS/Atom) <ref/contrib/syndication>`
* :doc:`Comments <ref/contrib/comments/index>`, :doc:`comment moderation <ref/contrib/comments/moderation>` and :doc:`custom comments <ref/contrib/comments/custom>` * :doc:`Comments <ref/contrib/comments/index>`, :doc:`comment moderation <ref/contrib/comments/moderation>` and :doc:`custom comments <ref/contrib/comments/custom>`
* :doc:`Pagination <topics/pagination>` * :doc:`Pagination <topics/pagination>`

View File

@ -23,7 +23,7 @@ these changes.
* The :mod:`django.contrib.gis.db.backend` module will be removed in favor * The :mod:`django.contrib.gis.db.backend` module will be removed in favor
of the specific backends. of the specific backends.
* ``SMTPConnection`` will be removed in favor of a generic E-mail backend API. * ``SMTPConnection`` will be removed in favor of a generic Email backend API.
* The many to many SQL generation functions on the database backends * The many to many SQL generation functions on the database backends
will be removed. will be removed.

View File

@ -455,7 +455,7 @@ This example illustrates all possible attributes and methods for a
author_name = 'Sally Smith' # Hard-coded author name. author_name = 'Sally Smith' # Hard-coded author name.
# AUTHOR E-MAIL --One of the following three is optional. The framework # AUTHOR EMAIL --One of the following three is optional. The framework
# looks for them in this order. # looks for them in this order.
def author_email(self, obj): def author_email(self, obj):
@ -635,7 +635,7 @@ This example illustrates all possible attributes and methods for a
item_author_name = 'Sally Smith' # Hard-coded author name. item_author_name = 'Sally Smith' # Hard-coded author name.
# ITEM AUTHOR E-MAIL --One of the following three is optional. The # ITEM AUTHOR EMAIL --One of the following three is optional. The
# framework looks for them in this order. # framework looks for them in this order.
# #
# If you specify this, you must specify item_author_name. # If you specify this, you must specify item_author_name.

View File

@ -105,7 +105,7 @@ Access the :attr:`~Form.errors` attribute to get a dictionary of error
messages:: messages::
>>> f.errors >>> f.errors
{'sender': [u'Enter a valid e-mail address.'], 'subject': [u'This field is required.']} {'sender': [u'Enter a valid email address.'], 'subject': [u'This field is required.']}
In this dictionary, the keys are the field names, and the values are lists of In this dictionary, the keys are the field names, and the values are lists of
Unicode strings representing the error messages. The error messages are stored Unicode strings representing the error messages. The error messages are stored
@ -538,18 +538,18 @@ method you're using::
>>> print(f.as_table()) >>> print(f.as_table())
<tr><th>Subject:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="subject" maxlength="100" /></td></tr> <tr><th>Subject:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="subject" maxlength="100" /></td></tr>
<tr><th>Message:</th><td><input type="text" name="message" value="Hi there" /></td></tr> <tr><th>Message:</th><td><input type="text" name="message" value="Hi there" /></td></tr>
<tr><th>Sender:</th><td><ul class="errorlist"><li>Enter a valid e-mail address.</li></ul><input type="text" name="sender" value="invalid email address" /></td></tr> <tr><th>Sender:</th><td><ul class="errorlist"><li>Enter a valid email address.</li></ul><input type="text" name="sender" value="invalid email address" /></td></tr>
<tr><th>Cc myself:</th><td><input checked="checked" type="checkbox" name="cc_myself" /></td></tr> <tr><th>Cc myself:</th><td><input checked="checked" type="checkbox" name="cc_myself" /></td></tr>
>>> print(f.as_ul()) >>> print(f.as_ul())
<li><ul class="errorlist"><li>This field is required.</li></ul>Subject: <input type="text" name="subject" maxlength="100" /></li> <li><ul class="errorlist"><li>This field is required.</li></ul>Subject: <input type="text" name="subject" maxlength="100" /></li>
<li>Message: <input type="text" name="message" value="Hi there" /></li> <li>Message: <input type="text" name="message" value="Hi there" /></li>
<li><ul class="errorlist"><li>Enter a valid e-mail address.</li></ul>Sender: <input type="text" name="sender" value="invalid email address" /></li> <li><ul class="errorlist"><li>Enter a valid email address.</li></ul>Sender: <input type="text" name="sender" value="invalid email address" /></li>
<li>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></li> <li>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></li>
>>> print(f.as_p()) >>> print(f.as_p())
<p><ul class="errorlist"><li>This field is required.</li></ul></p> <p><ul class="errorlist"><li>This field is required.</li></ul></p>
<p>Subject: <input type="text" name="subject" maxlength="100" /></p> <p>Subject: <input type="text" name="subject" maxlength="100" /></p>
<p>Message: <input type="text" name="message" value="Hi there" /></p> <p>Message: <input type="text" name="message" value="Hi there" /></p>
<p><ul class="errorlist"><li>Enter a valid e-mail address.</li></ul></p> <p><ul class="errorlist"><li>Enter a valid email address.</li></ul></p>
<p>Sender: <input type="text" name="sender" value="invalid email address" /></p> <p>Sender: <input type="text" name="sender" value="invalid email address" /></p>
<p>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></p> <p>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></p>
@ -572,7 +572,7 @@ pass that in at construction time::
<div class="errorlist"><div class="error">This field is required.</div></div> <div class="errorlist"><div class="error">This field is required.</div></div>
<p>Subject: <input type="text" name="subject" maxlength="100" /></p> <p>Subject: <input type="text" name="subject" maxlength="100" /></p>
<p>Message: <input type="text" name="message" value="Hi there" /></p> <p>Message: <input type="text" name="message" value="Hi there" /></p>
<div class="errorlist"><div class="error">Enter a valid e-mail address.</div></div> <div class="errorlist"><div class="error">Enter a valid email address.</div></div>
<p>Sender: <input type="text" name="sender" value="invalid email address" /></p> <p>Sender: <input type="text" name="sender" value="invalid email address" /></p>
<p>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></p> <p>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></p>

View File

@ -28,7 +28,7 @@ exception or returns the clean value::
>>> f.clean('invalid email address') >>> f.clean('invalid email address')
Traceback (most recent call last): Traceback (most recent call last):
... ...
ValidationError: [u'Enter a valid e-mail address.'] ValidationError: [u'Enter a valid email address.']
Core field arguments Core field arguments
-------------------- --------------------

View File

@ -185,7 +185,7 @@ a look at Django's ``EmailField``::
class EmailField(CharField): class EmailField(CharField):
default_error_messages = { default_error_messages = {
'invalid': _('Enter a valid e-mail address.'), 'invalid': _('Enter a valid email address.'),
} }
default_validators = [validators.validate_email] default_validators = [validators.validate_email]
@ -198,7 +198,7 @@ on field definition so::
is equivalent to:: is equivalent to::
email = forms.CharField(validators=[validators.validate_email], email = forms.CharField(validators=[validators.validate_email],
error_messages={'invalid': _('Enter a valid e-mail address.')}) error_messages={'invalid': _('Enter a valid email address.')})
Form field default cleaning Form field default cleaning

View File

@ -1622,7 +1622,7 @@ your test suite.
"a@a.com" as a valid email address, but rejects "aaa" with a reasonable "a@a.com" as a valid email address, but rejects "aaa" with a reasonable
error message:: error message::
self.assertFieldOutput(EmailField, {'a@a.com': 'a@a.com'}, {'aaa': [u'Enter a valid e-mail address.']}) self.assertFieldOutput(EmailField, {'a@a.com': 'a@a.com'}, {'aaa': [u'Enter a valid email address.']})
.. method:: TestCase.assertContains(response, text, count=None, status_code=200, msg_prefix='', html=False) .. method:: TestCase.assertContains(response, text, count=None, status_code=200, msg_prefix='', html=False)

View File

@ -215,7 +215,7 @@ class ClientTest(TestCase):
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "Invalid POST Template") self.assertTemplateUsed(response, "Invalid POST Template")
self.assertFormError(response, 'form', 'email', 'Enter a valid e-mail address.') self.assertFormError(response, 'form', 'email', 'Enter a valid email address.')
def test_valid_form_with_template(self): def test_valid_form_with_template(self):
"POST valid data to a form using multiple templates" "POST valid data to a form using multiple templates"
@ -263,7 +263,7 @@ class ClientTest(TestCase):
self.assertTemplateUsed(response, 'base.html') self.assertTemplateUsed(response, 'base.html')
self.assertTemplateNotUsed(response, "Invalid POST Template") self.assertTemplateNotUsed(response, "Invalid POST Template")
self.assertFormError(response, 'form', 'email', 'Enter a valid e-mail address.') self.assertFormError(response, 'form', 'email', 'Enter a valid email address.')
def test_unknown_page(self): def test_unknown_page(self):
"GET an invalid URL" "GET an invalid URL"

View File

@ -897,7 +897,7 @@ class AdminViewPermissionsTest(TestCase):
self.assertFalse(login.context) self.assertFalse(login.context)
self.client.get('/test_admin/admin/logout/') self.client.get('/test_admin/admin/logout/')
# Test if user enters e-mail address # Test if user enters email address
response = self.client.get('/test_admin/admin/') response = self.client.get('/test_admin/admin/')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
login = self.client.post('/test_admin/admin/', self.super_email_login) login = self.client.post('/test_admin/admin/', self.super_email_login)
@ -907,7 +907,7 @@ class AdminViewPermissionsTest(TestCase):
self.assertContains(login, ERROR_MESSAGE) self.assertContains(login, ERROR_MESSAGE)
new_user = User(username='jondoe', password='secret', email='super@example.com') new_user = User(username='jondoe', password='secret', email='super@example.com')
new_user.save() new_user.save()
# check to ensure if there are multiple e-mail addresses a user doesn't get a 500 # check to ensure if there are multiple email addresses a user doesn't get a 500
login = self.client.post('/test_admin/admin/', self.super_email_login) login = self.client.post('/test_admin/admin/', self.super_email_login)
self.assertContains(login, ERROR_MESSAGE) self.assertContains(login, ERROR_MESSAGE)
@ -1556,7 +1556,7 @@ class SecureViewTests(TestCase):
# make sure the view removes test cookie # make sure the view removes test cookie
self.assertEqual(self.client.session.test_cookie_worked(), False) self.assertEqual(self.client.session.test_cookie_worked(), False)
# Test if user enters e-mail address # Test if user enters email address
response = self.client.get('/test_admin/admin/secure-view/') response = self.client.get('/test_admin/admin/secure-view/')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
login = self.client.post('/test_admin/admin/secure-view/', self.super_email_login) login = self.client.post('/test_admin/admin/secure-view/', self.super_email_login)
@ -1566,7 +1566,7 @@ class SecureViewTests(TestCase):
self.assertContains(login, ERROR_MESSAGE) self.assertContains(login, ERROR_MESSAGE)
new_user = User(username='jondoe', password='secret', email='super@example.com') new_user = User(username='jondoe', password='secret', email='super@example.com')
new_user.save() new_user.save()
# check to ensure if there are multiple e-mail addresses a user doesn't get a 500 # check to ensure if there are multiple email addresses a user doesn't get a 500
login = self.client.post('/test_admin/admin/secure-view/', self.super_email_login) login = self.client.post('/test_admin/admin/secure-view/', self.super_email_login)
self.assertContains(login, ERROR_MESSAGE) self.assertContains(login, ERROR_MESSAGE)

View File

@ -613,7 +613,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
data = dict(email='invalid') data = dict(email='invalid')
f = CommentForm(data, auto_id=False, error_class=DivErrorList) f = CommentForm(data, auto_id=False, error_class=DivErrorList)
self.assertHTMLEqual(f.as_p(), """<p>Name: <input type="text" name="name" maxlength="50" /></p> self.assertHTMLEqual(f.as_p(), """<p>Name: <input type="text" name="name" maxlength="50" /></p>
<div class="errorlist"><div class="error">Enter a valid e-mail address.</div></div> <div class="errorlist"><div class="error">Enter a valid email address.</div></div>
<p>Email: <input type="text" name="email" value="invalid" /></p> <p>Email: <input type="text" name="email" value="invalid" /></p>
<div class="errorlist"><div class="error">This field is required.</div></div> <div class="errorlist"><div class="error">This field is required.</div></div>
<p>Comment: <input type="text" name="comment" /></p>""") <p>Comment: <input type="text" name="comment" /></p>""")

View File

@ -507,16 +507,16 @@ class FieldsTests(SimpleTestCase):
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, '') self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, '')
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, None) self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, None)
self.assertEqual('person@example.com', f.clean('person@example.com')) self.assertEqual('person@example.com', f.clean('person@example.com'))
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'foo') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'foo')
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'foo@') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'foo@')
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'foo@bar') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'foo@bar')
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'example@invalid-.com') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'example@invalid-.com')
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'example@-invalid.com') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'example@-invalid.com')
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'example@inv-.alid-.com') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'example@inv-.alid-.com')
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'example@inv-.-alid.com') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'example@inv-.-alid.com')
self.assertEqual('example@valid-----hyphens.com', f.clean('example@valid-----hyphens.com')) self.assertEqual('example@valid-----hyphens.com', f.clean('example@valid-----hyphens.com'))
self.assertEqual('example@valid-with-hyphens.com', f.clean('example@valid-with-hyphens.com')) self.assertEqual('example@valid-with-hyphens.com', f.clean('example@valid-with-hyphens.com'))
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'example@.com') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'example@.com')
self.assertEqual('local@domain.with.idn.xyz\xe4\xf6\xfc\xdfabc.part.com', f.clean('local@domain.with.idn.xyzäöüßabc.part.com')) self.assertEqual('local@domain.with.idn.xyz\xe4\xf6\xfc\xdfabc.part.com', f.clean('local@domain.with.idn.xyzäöüßabc.part.com'))
def test_email_regexp_for_performance(self): def test_email_regexp_for_performance(self):
@ -525,7 +525,7 @@ class FieldsTests(SimpleTestCase):
# if the security fix isn't in place. # if the security fix isn't in place.
self.assertRaisesMessage( self.assertRaisesMessage(
ValidationError, ValidationError,
"'Enter a valid e-mail address.'", "'Enter a valid email address.'",
f.clean, f.clean,
'viewx3dtextx26qx3d@yahoo.comx26latlngx3d15854521645943074058' 'viewx3dtextx26qx3d@yahoo.comx26latlngx3d15854521645943074058'
) )
@ -536,9 +536,9 @@ class FieldsTests(SimpleTestCase):
self.assertEqual('', f.clean(None)) self.assertEqual('', f.clean(None))
self.assertEqual('person@example.com', f.clean('person@example.com')) self.assertEqual('person@example.com', f.clean('person@example.com'))
self.assertEqual('example@example.com', f.clean(' example@example.com \t \t ')) self.assertEqual('example@example.com', f.clean(' example@example.com \t \t '))
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'foo') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'foo')
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'foo@') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'foo@')
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'foo@bar') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'foo@bar')
def test_emailfield_3(self): def test_emailfield_3(self):
f = EmailField(min_length=10, max_length=15) f = EmailField(min_length=10, max_length=15)
@ -926,7 +926,7 @@ class FieldsTests(SimpleTestCase):
f = ComboField(fields=[CharField(max_length=20), EmailField()]) f = ComboField(fields=[CharField(max_length=20), EmailField()])
self.assertEqual('test@example.com', f.clean('test@example.com')) self.assertEqual('test@example.com', f.clean('test@example.com'))
self.assertRaisesMessage(ValidationError, "'Ensure this value has at most 20 characters (it has 28).'", f.clean, 'longemailaddress@example.com') self.assertRaisesMessage(ValidationError, "'Ensure this value has at most 20 characters (it has 28).'", f.clean, 'longemailaddress@example.com')
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'not an e-mail') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'not an email')
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, '') self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, '')
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, None) self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, None)
@ -934,7 +934,7 @@ class FieldsTests(SimpleTestCase):
f = ComboField(fields=[CharField(max_length=20), EmailField()], required=False) f = ComboField(fields=[CharField(max_length=20), EmailField()], required=False)
self.assertEqual('test@example.com', f.clean('test@example.com')) self.assertEqual('test@example.com', f.clean('test@example.com'))
self.assertRaisesMessage(ValidationError, "'Ensure this value has at most 20 characters (it has 28).'", f.clean, 'longemailaddress@example.com') self.assertRaisesMessage(ValidationError, "'Ensure this value has at most 20 characters (it has 28).'", f.clean, 'longemailaddress@example.com')
self.assertRaisesMessage(ValidationError, "'Enter a valid e-mail address.'", f.clean, 'not an e-mail') self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'", f.clean, 'not an email')
self.assertEqual('', f.clean('')) self.assertEqual('', f.clean(''))
self.assertEqual('', f.clean(None)) self.assertEqual('', f.clean(None))

View File

@ -499,11 +499,11 @@ class AssertFormErrorTests(TestCase):
try: try:
self.assertFormError(response, 'form', 'email', 'Some error.') self.assertFormError(response, 'form', 'email', 'Some error.')
except AssertionError as e: except AssertionError as e:
self.assertIn(str_prefix("The field 'email' on form 'form' in context 0 does not contain the error 'Some error.' (actual errors: [%(_)s'Enter a valid e-mail address.'])"), str(e)) self.assertIn(str_prefix("The field 'email' on form 'form' in context 0 does not contain the error 'Some error.' (actual errors: [%(_)s'Enter a valid email address.'])"), str(e))
try: try:
self.assertFormError(response, 'form', 'email', 'Some error.', msg_prefix='abc') self.assertFormError(response, 'form', 'email', 'Some error.', msg_prefix='abc')
except AssertionError as e: except AssertionError as e:
self.assertIn(str_prefix("abc: The field 'email' on form 'form' in context 0 does not contain the error 'Some error.' (actual errors: [%(_)s'Enter a valid e-mail address.'])"), str(e)) self.assertIn(str_prefix("abc: The field 'email' on form 'form' in context 0 does not contain the error 'Some error.' (actual errors: [%(_)s'Enter a valid email address.'])"), str(e))
def test_unknown_nonfield_error(self): def test_unknown_nonfield_error(self):
""" """

View File

@ -476,7 +476,7 @@ class AssertRaisesMsgTest(SimpleTestCase):
class AssertFieldOutputTests(SimpleTestCase): class AssertFieldOutputTests(SimpleTestCase):
def test_assert_field_output(self): def test_assert_field_output(self):
error_invalid = ['Enter a valid e-mail address.'] error_invalid = ['Enter a valid email address.']
self.assertFieldOutput(EmailField, {'a@a.com': 'a@a.com'}, {'aaa': error_invalid}) self.assertFieldOutput(EmailField, {'a@a.com': 'a@a.com'}, {'aaa': error_invalid})
self.assertRaises(AssertionError, self.assertFieldOutput, EmailField, {'a@a.com': 'a@a.com'}, {'aaa': error_invalid + ['Another error']}) self.assertRaises(AssertionError, self.assertFieldOutput, EmailField, {'a@a.com': 'a@a.com'}, {'aaa': error_invalid + ['Another error']})
self.assertRaises(AssertionError, self.assertFieldOutput, EmailField, {'a@a.com': 'Wrong output'}, {'aaa': error_invalid}) self.assertRaises(AssertionError, self.assertFieldOutput, EmailField, {'a@a.com': 'Wrong output'}, {'aaa': error_invalid})