Code

Ticket #10818: 10818.diff

File 10818.diff, 4.0 KB (added by SmileyChris, 5 years ago)
Line 
1### Eclipse Workspace Patch 1.0
2#P Django trunk
3Index: django/contrib/auth/tests/views.py
4===================================================================
5--- django/contrib/auth/tests/views.py  (revision 10433)
6+++ django/contrib/auth/tests/views.py  (working copy)
7@@ -10,10 +10,22 @@
8 from django.core import mail
9 from django.core.urlresolvers import reverse
10 
11-class PasswordResetTest(TestCase):
12+
13+class BaseAuthTest(TestCase):
14     fixtures = ['authtestdata.json']
15     urls = 'django.contrib.auth.urls'
16 
17+    def setUp(self):
18+        self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
19+        settings.TEMPLATE_DIRS = (
20+            os.path.join(os.path.dirname(__file__), 'templates'),
21+        )
22+
23+    def tearDown(self):
24+        settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
25+
26+
27+class PasswordResetTest(BaseAuthTest):
28     def test_email_not_found(self):
29         "Error is raised if the provided email address isn't currently registered"
30         response = self.client.get('/password_reset/')
31@@ -93,22 +105,7 @@
32         self.assert_("The two password fields didn't match" in response.content)
33 
34 
35-class ChangePasswordTest(TestCase):
36-    fixtures = ['authtestdata.json']
37-    urls = 'django.contrib.auth.urls'
38-
39-    def setUp(self):
40-        self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
41-        settings.TEMPLATE_DIRS = (
42-            os.path.join(
43-                os.path.dirname(__file__),
44-                'templates'
45-            )
46-        ,)
47-
48-    def tearDown(self):
49-        settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
50-
51+class ChangePasswordTest(BaseAuthTest):
52     def login(self, password='password'):
53         response = self.client.post('/login/', {
54             'username': 'testclient',
55@@ -165,27 +162,19 @@
56         self.fail_login()
57         self.login(password='password1')
58 
59-class LoginTest(TestCase):
60-    fixtures = ['authtestdata.json']
61-    urls = 'django.contrib.auth.urls'
62 
63-    def setUp(self):
64-        self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
65-        settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
66-
67-    def tearDown(self):
68-        settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
69-
70+class LoginTest(BaseAuthTest):
71     def test_current_site_in_context_after_login(self):
72         response = self.client.get(reverse('django.contrib.auth.views.login'))
73         self.assertEquals(response.status_code, 200)
74         site = Site.objects.get_current()
75         self.assertEquals(response.context['site'], site)
76         self.assertEquals(response.context['site_name'], site.name)
77-        self.assert_(isinstance(response.context['form'], AuthenticationForm),
78+        self.assert_(isinstance(response.context['form'], AuthenticationForm),
79                      'Login form is not an AuthenticationForm')
80-       
81-class LogoutTest(TestCase):
82+
83+
84+class LogoutTest(BaseAuthTest):
85     fixtures = ['authtestdata.json']
86     urls = 'django.contrib.auth.tests.urls'
87 
88@@ -210,7 +199,7 @@
89         self.assert_('Logged out' in response.content)
90         self.confirm_logged_out()
91 
92-    def test_logout_with_next_page_specified(self):
93+    def test_logout_with_next_page_specified(self):
94         "Logout with next_page option given redirects to specified resource"
95         self.login()
96         response = self.client.get('/logout/next_page/')
97Index: django/contrib/auth/tests/templates/registration/password_reset_form.html
98===================================================================
99--- django/contrib/auth/tests/templates/registration/password_reset_form.html   (revision 0)
100+++ django/contrib/auth/tests/templates/registration/password_reset_form.html   (revision 0)
101@@ -0,0 +1 @@
102+{{ form.as_ul }}
103\ No newline at end of file
104Index: django/contrib/auth/tests/templates/registration/password_change_form.html
105===================================================================
106--- django/contrib/auth/tests/templates/registration/password_change_form.html  (revision 0)
107+++ django/contrib/auth/tests/templates/registration/password_change_form.html  (revision 0)
108@@ -0,0 +1 @@
109+{{ form.as_ul }}
110\ No newline at end of file