Commit 9faa1cd9 authored by Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss
Browse files

Fixed #10747: fixed the auth tests to ignore broken user-supplied login/logout templates.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10482 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 49b2fc0c
Loading
Loading
Loading
Loading
+21 −29
Original line number Diff line number Diff line
@@ -10,10 +10,27 @@ from django.test import TestCase
from django.core import mail
from django.core.urlresolvers import reverse

class PasswordResetTest(TestCase):
class AuthViewsTestCase(TestCase):
    """
    Helper base class for all the follow test cases.
    """
    fixtures = ['authtestdata.json']
    urls = 'django.contrib.auth.urls'

    def setUp(self):
        self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
        settings.TEMPLATE_DIRS = (
            os.path.join(
                os.path.dirname(__file__),
                'templates'
            )
        ,)

    def tearDown(self):
        settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS

class PasswordResetTest(AuthViewsTestCase):

    def test_email_not_found(self):
        "Error is raised if the provided email address isn't currently registered"
        response = self.client.get('/password_reset/')
@@ -92,22 +109,7 @@ class PasswordResetTest(TestCase):
        self.assertEquals(response.status_code, 200)
        self.assert_("The two password fields didn't match" in response.content)


class ChangePasswordTest(TestCase):
    fixtures = ['authtestdata.json']
    urls = 'django.contrib.auth.urls'

    def setUp(self):
        self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
        settings.TEMPLATE_DIRS = (
            os.path.join(
                os.path.dirname(__file__),
                'templates'
            )
        ,)

    def tearDown(self):
        settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
class ChangePasswordTest(AuthViewsTestCase):

    def login(self, password='password'):
        response = self.client.post('/login/', {
@@ -165,16 +167,7 @@ class ChangePasswordTest(TestCase):
        self.fail_login()
        self.login(password='password1')

class LoginTest(TestCase):
    fixtures = ['authtestdata.json']
    urls = 'django.contrib.auth.urls'

    def setUp(self):
        self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
        settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)

    def tearDown(self):
        settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
class LoginTest(AuthViewsTestCase):

    def test_current_site_in_context_after_login(self):
        response = self.client.get(reverse('django.contrib.auth.views.login'))
@@ -185,8 +178,7 @@ class LoginTest(TestCase):
        self.assert_(isinstance(response.context['form'], AuthenticationForm), 
                     'Login form is not an AuthenticationForm')
        
class LogoutTest(TestCase):
    fixtures = ['authtestdata.json']
class LogoutTest(AuthViewsTestCase):
    urls = 'django.contrib.auth.tests.urls'

    def login(self, password='password'):