Ticket #9978: 9788.diff

File 9788.diff, 2.2 KB (added by Eric Holscher, 16 years ago)
  • django/test/client.py

     
    414414        Causes the authenticated user to be logged out.
    415415        """
    416416        session = __import__(settings.SESSION_ENGINE, {}, {}, ['']).SessionStore()
    417         session.delete(session_key=self.cookies[settings.SESSION_COOKIE_NAME].value)
     417        if self.cookies.has_key(settings.SESSION_COOKIE_NAME):
     418            session.delete(session_key=self.cookies[settings.SESSION_COOKIE_NAME].value)
    418419        self.cookies = SimpleCookie()
  • tests/modeltests/test_client/models.py

     
    7070        self.assertEqual(response.context['data'], '37')
    7171        self.assertEqual(response.template.name, 'POST Template')
    7272        self.failUnless('Data received' in response.content)
    73    
     73
    7474    def test_response_headers(self):
    7575        "Check the value of HTTP headers returned in a response"
    7676        response = self.client.get("/test_client/header_view/")
    77        
     77
    7878        self.assertEquals(response['X-DJANGO-TEST'], 'Slartibartfast')
    79        
     79
    8080    def test_raw_post(self):
    8181        "POST raw data (with a content type) to a view"
    8282        test_doc = """<?xml version="1.0" encoding="utf-8"?><library><book><title>Blink</title><author>Malcolm Gladwell</author></book></library>"""
     
    326326        response = self.client.get('/test_client/login_protected_view/')
    327327        self.assertRedirects(response, 'http://testserver/accounts/login/?next=/test_client/login_protected_view/')
    328328
     329
     330    def test_null_logout(self):
     331        #Logging out should do nothing, not raise a KeyError
     332        #Ref ticket #9978
     333        self.client.logout()
     334
    329335    def test_view_with_permissions(self):
    330336        "Request a page that is protected with @permission_required"
    331337
     
    417423        self.assertEqual(mail.outbox[1].from_email, 'from@example.com')
    418424        self.assertEqual(mail.outbox[1].to[0], 'second@example.com')
    419425        self.assertEqual(mail.outbox[1].to[1], 'third@example.com')
    420 
Back to Top