diff options
| author | Gary Wilson Jr <gary.wilson@gmail.com> | 2009-03-30 23:20:10 +0000 |
|---|---|---|
| committer | Gary Wilson Jr <gary.wilson@gmail.com> | 2009-03-30 23:20:10 +0000 |
| commit | 9bbf94112f011276d4e25b21676cfc2b74aaaef5 (patch) | |
| tree | 3e3899806016ffe898221a13ec28f3c68ced2655 /django | |
| parent | 22ac97b17cbc3491629f98b15cc9a699b14ebd73 (diff) | |
[1.0.X]: Fixed #9978 -- Fixed a KeyError exception that was being raised when using the logout method on the test client on an unauthenticated user, based on patch from ericholscher.
Backport of r10228 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10236 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/test/client.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/django/test/client.py b/django/test/client.py index f4435c090f..b144fe2fdb 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -334,10 +334,12 @@ class Client(object): def logout(self): """ - Removes the authenticated user's cookies. + Removes the authenticated user's cookies and session object. Causes the authenticated user to be logged out. """ session = __import__(settings.SESSION_ENGINE, {}, {}, ['']).SessionStore() - session.delete(session_key=self.cookies[settings.SESSION_COOKIE_NAME].value) + session_cookie = self.cookies.get(settings.SESSION_COOKIE_NAME) + if session_cookie: + session.delete(session_key=session_cookie.value) self.cookies = SimpleCookie() |
