Ticket #10818: 10818.diff

File 10818.diff, 4.0 KB (added by Chris Beaven, 16 years ago)
  • django/contrib/auth/tests/views.py

    ### Eclipse Workspace Patch 1.0
    #P Django trunk
     
    1010from django.core import mail
    1111from django.core.urlresolvers import reverse
    1212
    13 class PasswordResetTest(TestCase):
     13
     14class BaseAuthTest(TestCase):
    1415    fixtures = ['authtestdata.json']
    1516    urls = 'django.contrib.auth.urls'
    1617
     18    def setUp(self):
     19        self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
     20        settings.TEMPLATE_DIRS = (
     21            os.path.join(os.path.dirname(__file__), 'templates'),
     22        )
     23
     24    def tearDown(self):
     25        settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
     26
     27
     28class PasswordResetTest(BaseAuthTest):
    1729    def test_email_not_found(self):
    1830        "Error is raised if the provided email address isn't currently registered"
    1931        response = self.client.get('/password_reset/')
     
    93105        self.assert_("The two password fields didn't match" in response.content)
    94106
    95107
    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
    111 
     108class ChangePasswordTest(BaseAuthTest):
    112109    def login(self, password='password'):
    113110        response = self.client.post('/login/', {
    114111            'username': 'testclient',
     
    165162        self.fail_login()
    166163        self.login(password='password1')
    167164
    168 class LoginTest(TestCase):
    169     fixtures = ['authtestdata.json']
    170     urls = 'django.contrib.auth.urls'
    171165
    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
    178 
     166class LoginTest(BaseAuthTest):
    179167    def test_current_site_in_context_after_login(self):
    180168        response = self.client.get(reverse('django.contrib.auth.views.login'))
    181169        self.assertEquals(response.status_code, 200)
    182170        site = Site.objects.get_current()
    183171        self.assertEquals(response.context['site'], site)
    184172        self.assertEquals(response.context['site_name'], site.name)
    185         self.assert_(isinstance(response.context['form'], AuthenticationForm), 
     173        self.assert_(isinstance(response.context['form'], AuthenticationForm),
    186174                     'Login form is not an AuthenticationForm')
    187        
    188 class LogoutTest(TestCase):
     175
     176
     177class LogoutTest(BaseAuthTest):
    189178    fixtures = ['authtestdata.json']
    190179    urls = 'django.contrib.auth.tests.urls'
    191180
     
    210199        self.assert_('Logged out' in response.content)
    211200        self.confirm_logged_out()
    212201
    213     def test_logout_with_next_page_specified(self): 
     202    def test_logout_with_next_page_specified(self):
    214203        "Logout with next_page option given redirects to specified resource"
    215204        self.login()
    216205        response = self.client.get('/logout/next_page/')
  • django/contrib/auth/tests/templates/registration/password_reset_form.html

     
     1{{ form.as_ul }}
     2 No newline at end of file
  • django/contrib/auth/tests/templates/registration/password_change_form.html

     
     1{{ form.as_ul }}
     2 No newline at end of file
Back to Top