#17980: Tests fail when i18n set to True.
------------------------------+------------------------------------
     Reporter:  wassup        |                    Owner:  nobody
         Type:  Bug           |                   Status:  new
    Component:  contrib.auth  |                  Version:  1.4
     Severity:  Normal        |               Resolution:
     Keywords:  tests         |             Triage Stage:  Accepted
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+------------------------------------

Old description:

> Hi,
>
> When i18n is set to True and project language is not English, some of the
> default django tests do not pass (it worked fine in 1.3). I believe the
> reason is that the messages get translated and localized before the tests
> are run, which results in e.g.:
>

> ======================================================================
> FAIL: test_unusable_password
> (django.contrib.auth.tests.forms.PasswordResetFormTest)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/site-
> packages/django/contrib/auth/tests/forms.py", line 336, in
> test_unusable_password
>     [u"The user account associated with this e-mail address cannot reset
> the password."])
> AssertionError: [u'U\u017cytkownik, kt\xf3rego konto powi\u0105zane jest
> z tym adresem e-mail nie mo\u017ce zresetowa\u0107 has\u0142a.'] !=
> [u'The user account associated with this e-mail address cannot reset the
> password.']
>
> ======================================================================
> FAIL: test_confirm_different_passwords
> (django.contrib.auth.tests.views.PasswordResetTest)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/site-
> packages/django/contrib/auth/tests/views.py", line 184, in
> test_confirm_different_passwords
>     self.assertContainsEscaped(response,
> SetPasswordForm.error_messages['password_mismatch'])
>   File "/usr/lib/python2.7/site-
> packages/django/contrib/auth/tests/views.py", line 54, in
> assertContainsEscaped
>     return self.assertContains(response, escape(force_unicode(text)),
> **kwargs)
>   File "/usr/lib/python2.7/site-packages/django/test/testcases.py", line
> 637, in assertContains
>     msg_prefix + "Couldn't find '%s' in response" % text)
> AssertionError: Couldn't find 'Hasła się nie zgadzają.' in response
>
> ======================================================================
> FAIL: test_email_not_found
> (django.contrib.auth.tests.views.PasswordResetTest)
> Error is raised if the provided email address isn't currently registered
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/site-
> packages/django/contrib/auth/tests/views.py", line 91, in
> test_email_not_found
>     self.assertContainsEscaped(response,
> PasswordResetForm.error_messages['unknown'])
>   File "/usr/lib/python2.7/site-
> packages/django/contrib/auth/tests/views.py", line 54, in
> assertContainsEscaped
>     return self.assertContains(response, escape(force_unicode(text)),
> **kwargs)
>   File "/usr/lib/python2.7/site-packages/django/test/testcases.py", line
> 637, in assertContains
>     msg_prefix + "Couldn't find '%s' in response" % text)
> AssertionError: Couldn't find 'Ten adres e-mail nie ma przypisanego
> konta. Jesteś pewien, że zarejestrowałeś się?' in response
>
> ----------------------------------------------------------------------
>
> I believe the default django tests should not be run against the
> localized strings or am I missing something?
>
> Regards,
>
> wassup

New description:

 Hi,

 When i18n is set to True and project language is not English, some of the
 default django tests do not pass (it worked fine in 1.3). I believe the
 reason is that the messages get translated and localized before the tests
 are run, which results in e.g.:

 {{{
 ======================================================================
 FAIL: test_unusable_password
 (django.contrib.auth.tests.forms.PasswordResetFormTest)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/usr/lib/python2.7/site-
 packages/django/contrib/auth/tests/forms.py", line 336, in
 test_unusable_password
     [u"The user account associated with this e-mail address cannot reset
 the password."])
 AssertionError: [u'U\u017cytkownik, kt\xf3rego konto powi\u0105zane jest z
 tym adresem e-mail nie mo\u017ce zresetowa\u0107 has\u0142a.'] != [u'The
 user account associated with this e-mail address cannot reset the
 password.']

 ======================================================================
 FAIL: test_confirm_different_passwords
 (django.contrib.auth.tests.views.PasswordResetTest)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/usr/lib/python2.7/site-
 packages/django/contrib/auth/tests/views.py", line 184, in
 test_confirm_different_passwords
     self.assertContainsEscaped(response,
 SetPasswordForm.error_messages['password_mismatch'])
   File "/usr/lib/python2.7/site-
 packages/django/contrib/auth/tests/views.py", line 54, in
 assertContainsEscaped
     return self.assertContains(response, escape(force_unicode(text)),
 **kwargs)
   File "/usr/lib/python2.7/site-packages/django/test/testcases.py", line
 637, in assertContains
     msg_prefix + "Couldn't find '%s' in response" % text)
 AssertionError: Couldn't find 'Hasła się nie zgadzają.' in response

 ======================================================================
 FAIL: test_email_not_found
 (django.contrib.auth.tests.views.PasswordResetTest)
 Error is raised if the provided email address isn't currently registered
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/usr/lib/python2.7/site-
 packages/django/contrib/auth/tests/views.py", line 91, in
 test_email_not_found
     self.assertContainsEscaped(response,
 PasswordResetForm.error_messages['unknown'])
   File "/usr/lib/python2.7/site-
 packages/django/contrib/auth/tests/views.py", line 54, in
 assertContainsEscaped
     return self.assertContains(response, escape(force_unicode(text)),
 **kwargs)
   File "/usr/lib/python2.7/site-packages/django/test/testcases.py", line
 637, in assertContains
     msg_prefix + "Couldn't find '%s' in response" % text)
 AssertionError: Couldn't find 'Ten adres e-mail nie ma przypisanego konta.
 Jesteś pewien, że zarejestrowałeś się?' in response

 ----------------------------------------------------------------------
 }}}

 I believe the default django tests should not be run against the localized
 strings or am I missing something?

 Regards,

 wassup

--

Comment (by jezdez):

 Fixed formatting, please use Trac's preview feature.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17980#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to