Ticket #7611: 7611_r7977.diff

File 7611_r7977.diff, 2.0 KB (added by jason, 7 years ago)
  • django/contrib/auth/tests/basic.py

     
    5555u'!'
    5656"""
    5757
     58from django.core import mail, urlresolvers
    5859from django.test import TestCase
    59 from django.core import mail
    6060
    6161class PasswordResetTest(TestCase):
    6262    fixtures = ['authtestdata.json']
    63     urls = 'django.contrib.auth.urls'
    64    
     63
     64    def setUp(self):
     65        try:
     66            self.url = urlresolvers.reverse('django.contrib.auth.views.password_reset')
     67        except urlresolvers.NoReverseMatch:
     68            self.url = None
     69
    6570    def test_email_not_found(self):
    6671        "Error is raised if the provided email address isn't currently registered"
    67         response = self.client.get('/password_reset/')
    68         self.assertEquals(response.status_code, 200)
    69         response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'})
    70         self.assertContains(response, "That e-mail address doesn't have an associated user account")
    71         self.assertEquals(len(mail.outbox), 0)
     72        if self.url:
     73            response = self.client.get(self.url)
     74            self.assertEquals(response.status_code, 200)
     75            response = self.client.post(self.url, {'email': 'not_a_real_email@email.com'})
     76            self.assertContains(response, "That e-mail address doesn't have an associated user account")
     77            self.assertEquals(len(mail.outbox), 0)
    7278   
    7379    def test_email_found(self):
    7480        "Email is sent if a valid email address is provided for password reset"
    75         response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})
    76         self.assertEquals(response.status_code, 302)
    77         self.assertEquals(len(mail.outbox), 1)
     81        if self.url:
     82            response = self.client.post(self.url, {'email': 'staffmember@example.com'})
     83            self.assertEquals(response.status_code, 302)
     84            self.assertEquals(len(mail.outbox), 1)
Back to Top