Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #10747: fixed the auth tests to ignore broken user-supplied log…

…in/logout templates.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10482 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9faa1cd9b59a2b035d6af79079c2f5eb7d43772c 1 parent 49b2fc0
@jacobian jacobian authored
Showing with 21 additions and 29 deletions.
  1. +21 −29 django/contrib/auth/tests/views.py
View
50 django/contrib/auth/tests/views.py
@@ -10,10 +10,27 @@
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 @@ def test_confirm_different_passwords(self):
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 @@ def test_password_change_succeeds(self):
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 @@ def test_current_site_in_context_after_login(self):
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'):
Please sign in to comment.
Something went wrong with that request. Please try again.