Ticket #16837: 16837.general_error_message.patch3.diff

File 16837.general_error_message.patch3.diff, 4.2 KB (added by Wim Feijen <wim@…>, 13 years ago)

Sets ERROR_MESSAGE in tests in stead of importing, in order to prevent double rainbows ;)

  • django/contrib/admin/forms.py

    diff --git a/django/contrib/admin/forms.py b/django/contrib/admin/forms.py
    index f26c100..e790e2e 100644
    a b from django.contrib.auth.models import User  
    66
    77from django.utils.translation import ugettext_lazy, ugettext as _
    88
    9 ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. "
    10                               "Note that both fields are case-sensitive.")
     9ERROR_MESSAGE = ugettext_lazy("Please enter the correct username and password "
     10        "for a staff account. Note that both fields are case-sensitive.")
    1111
    1212class AdminAuthenticationForm(AuthenticationForm):
    1313    """
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index 22b65a6..7ffbbdc 100644
    a b from models import (Article, BarAccount, CustomArticle, EmptyModel,  
    4040    RowLevelChangePermissionModel, Paper, CoverLetter, Story, OtherStory,
    4141    ComplexSortedPerson, Parent, Child)
    4242
     43ERROR_MESSAGE = "Please enter the correct username and password \
     44for a staff account. Note that both fields are case-sensitive."
     45
    4346
    4447class AdminViewBasicTest(TestCase):
    4548    fixtures = ['admin-views-users.xml', 'admin-views-colors.xml',
    class AdminViewPermissionsTest(TestCase):  
    754757        self.assertContains(login, "Your e-mail address is not your username")
    755758        # only correct passwords get a username hint
    756759        login = self.client.post('/test_admin/admin/', self.super_email_bad_login)
    757         self.assertContains(login, "Please enter a correct username and password.")
     760        self.assertContains(login, ERROR_MESSAGE)
    758761        new_user = User(username='jondoe', password='secret', email='super@example.com')
    759762        new_user.save()
    760763        # check to ensure if there are multiple e-mail addresses a user doesn't get a 500
    761764        login = self.client.post('/test_admin/admin/', self.super_email_login)
    762         self.assertContains(login, "Please enter a correct username and password.")
     765        self.assertContains(login, ERROR_MESSAGE)
    763766
    764767        # Add User
    765768        request = self.client.get('/test_admin/admin/')
    class AdminViewPermissionsTest(TestCase):  
    790793        self.assertEqual(request.status_code, 200)
    791794        login = self.client.post('/test_admin/admin/', self.joepublic_login)
    792795        self.assertEqual(login.status_code, 200)
    793         self.assertContains(login, "Please enter a correct username and password.")
     796        self.assertContains(login, ERROR_MESSAGE)
    794797
    795798        # Requests without username should not return 500 errors.
    796799        request = self.client.get('/test_admin/admin/')
    class SecureViewTests(TestCase):  
    13501353        self.assertContains(login, "Your e-mail address is not your username")
    13511354        # only correct passwords get a username hint
    13521355        login = self.client.post('/test_admin/admin/secure-view/', self.super_email_bad_login)
    1353         self.assertContains(login, "Please enter a correct username and password.")
     1356        self.assertContains(login, ERROR_MESSAGE)
    13541357        new_user = User(username='jondoe', password='secret', email='super@example.com')
    13551358        new_user.save()
    13561359        # check to ensure if there are multiple e-mail addresses a user doesn't get a 500
    13571360        login = self.client.post('/test_admin/admin/secure-view/', self.super_email_login)
    1358         self.assertContains(login, "Please enter a correct username and password.")
     1361        self.assertContains(login, ERROR_MESSAGE)
    13591362
    13601363        # Add User
    13611364        request = self.client.get('/test_admin/admin/secure-view/')
    class SecureViewTests(TestCase):  
    13871390        login = self.client.post('/test_admin/admin/secure-view/', self.joepublic_login)
    13881391        self.assertEqual(login.status_code, 200)
    13891392        # Login.context is a list of context dicts we just need to check the first one.
    1390         self.assertContains(login, "Please enter a correct username and password.")
     1393        self.assertContains(login, ERROR_MESSAGE)
    13911394
    13921395        # 8509 - if a normal user is already logged in, it is possible
    13931396        # to change user into the superuser without error
Back to Top