From 9faa1cd9b59a2b035d6af79079c2f5eb7d43772c Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Fri, 10 Apr 2009 15:50:51 +0000 Subject: [PATCH] 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 --- django/contrib/auth/tests/views.py | 50 +++++++++++++----------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/views.py index f2faf09228..68ab009365 100644 --- a/django/contrib/auth/tests/views.py +++ b/django/contrib/auth/tests/views.py @@ -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'):