Commits

Andrii Kostenko committed 96a3a85

ugettext for passing tests under django 1.4

Comments (0)

Files changed (2)

registration/tests/forms.py

 from django.contrib.auth.models import User
 from django.test import TestCase
+from django.utils.translation import gettext, ugettext
 
 from registration import forms
 
         for invalid_dict in invalid_data_dicts:
             form = forms.RegistrationForm(data=invalid_dict['data'])
             self.failIf(form.is_valid())
-            self.assertEqual(form.errors[invalid_dict['error'][0]],
-                             invalid_dict['error'][1])
+            self.assertEqual(form.errors[invalid_dict['error'][0]][0],
+                             ugettext(invalid_dict['error'][1][0]))
 
         form = forms.RegistrationForm(data={'username': 'foo',
                                             'email': 'foo@example.com',
                                                           'password2': 'foo'})
         self.failIf(form.is_valid())
         self.assertEqual(form.errors['tos'],
-                         [u"You must agree to the terms to register"])
+                         [ugettext("You must agree to the terms to register")])
 
         form = forms.RegistrationFormTermsOfService(data={'username': 'foo',
                                                           'email': 'foo@example.com',
                                                        'password2': 'foo'})
         self.failIf(form.is_valid())
         self.assertEqual(form.errors['email'],
-                         [u"This email address is already in use. Please supply a different email address."])
+                         [ugettext(u"This email address is already in use. Please supply a different email address.")])
 
         form = forms.RegistrationFormUniqueEmail(data={'username': 'foo',
                                                        'email': 'foo@example.com',
             form = forms.RegistrationFormNoFreeEmail(data=invalid_data)
             self.failIf(form.is_valid())
             self.assertEqual(form.errors['email'],
-                             [u"Registration using free email addresses is prohibited. Please supply a different email address."])
+                             [ugettext(u"Registration using free email addresses is prohibited. Please supply a different email address.")])
 
         base_data['email'] = 'foo@example.com'
         form = forms.RegistrationFormNoFreeEmail(data=base_data)

registration/tests/views.py

 from django.core.urlresolvers import reverse
 from django.test import TestCase
 from django.utils import translation
+from django.utils.translation import gettext
 
 from registration import forms
 from registration.models import RegistrationProfile
         self.assertEqual(response.status_code, 200)
         self.failIf(response.context['form'].is_valid())
         self.assertFormError(response, 'form', field=None,
-                             errors=u"The two password fields didn't match.")
+                             errors=gettext("The two password fields didn't match."))
         self.assertEqual(len(mail.outbox), 0)
 
     def test_registration_view_closed(self):