Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Jacob Kaplan-Moss authored April 10, 2009

Showing 1 changed file with 21 additions and 29 deletions. Show diff stats Hide diff stats

  1. 50  django/contrib/auth/tests/views.py
50  django/contrib/auth/tests/views.py
@@ -10,10 +10,27 @@
10 10
 from django.core import mail
11 11
 from django.core.urlresolvers import reverse
12 12
 
13  
-class PasswordResetTest(TestCase):
  13
+class AuthViewsTestCase(TestCase):
  14
+    """
  15
+    Helper base class for all the follow test cases.
  16
+    """
14 17
     fixtures = ['authtestdata.json']
15 18
     urls = 'django.contrib.auth.urls'
16 19
 
  20
+    def setUp(self):
  21
+        self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
  22
+        settings.TEMPLATE_DIRS = (
  23
+            os.path.join(
  24
+                os.path.dirname(__file__),
  25
+                'templates'
  26
+            )
  27
+        ,)
  28
+
  29
+    def tearDown(self):
  30
+        settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
  31
+
  32
+class PasswordResetTest(AuthViewsTestCase):
  33
+
17 34
     def test_email_not_found(self):
18 35
         "Error is raised if the provided email address isn't currently registered"
19 36
         response = self.client.get('/password_reset/')
@@ -92,22 +109,7 @@ def test_confirm_different_passwords(self):
92 109
         self.assertEquals(response.status_code, 200)
93 110
         self.assert_("The two password fields didn't match" in response.content)
94 111
 
95  
-
96  
-class ChangePasswordTest(TestCase):
97  
-    fixtures = ['authtestdata.json']
98  
-    urls = 'django.contrib.auth.urls'
99  
-
100  
-    def setUp(self):
101  
-        self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
102  
-        settings.TEMPLATE_DIRS = (
103  
-            os.path.join(
104  
-                os.path.dirname(__file__),
105  
-                'templates'
106  
-            )
107  
-        ,)
108  
-
109  
-    def tearDown(self):
110  
-        settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
  112
+class ChangePasswordTest(AuthViewsTestCase):
111 113
 
112 114
     def login(self, password='password'):
113 115
         response = self.client.post('/login/', {
@@ -165,16 +167,7 @@ def test_password_change_succeeds(self):
165 167
         self.fail_login()
166 168
         self.login(password='password1')
167 169
 
168  
-class LoginTest(TestCase):
169  
-    fixtures = ['authtestdata.json']
170  
-    urls = 'django.contrib.auth.urls'
171  
-
172  
-    def setUp(self):
173  
-        self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
174  
-        settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
175  
-
176  
-    def tearDown(self):
177  
-        settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
  170
+class LoginTest(AuthViewsTestCase):
178 171
 
179 172
     def test_current_site_in_context_after_login(self):
180 173
         response = self.client.get(reverse('django.contrib.auth.views.login'))
@@ -185,8 +178,7 @@ def test_current_site_in_context_after_login(self):
185 178
         self.assert_(isinstance(response.context['form'], AuthenticationForm), 
186 179
                      'Login form is not an AuthenticationForm')
187 180
         
188  
-class LogoutTest(TestCase):
189  
-    fixtures = ['authtestdata.json']
  181
+class LogoutTest(AuthViewsTestCase):
190 182
     urls = 'django.contrib.auth.tests.urls'
191 183
 
192 184
     def login(self, password='password'):

0 notes on commit 9faa1cd

Please sign in to comment.
Something went wrong with that request. Please try again.