summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2007-08-17 14:20:25 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2007-08-17 14:20:25 +0000
commit8dff1cd91dcef967c2bbcf23b4a32458c0e0f83f (patch)
treee316bfb9563bf4225e8d68695ead0d3a9807b12f /django
parent55c0b35acf6aad2c5287d196bed6eadb0cc50486 (diff)
Fixed #5189 -- Added logout method to test Client. Thanks, Jakub Wisniowski <restless.being@gmail.com>.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5916 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/test/client.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/django/test/client.py b/django/test/client.py
index 7e62715205..9ec3615973 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -253,3 +253,14 @@ class Client:
else:
return False
+ def logout(self):
+ """Removes the authenticated user's cookies.
+
+ Causes the authenticated user to be logged out.
+ """
+ try:
+ Session.objects.get(session_key=self.cookies['sessionid'].value).delete()
+ except KeyError:
+ pass
+
+ self.cookies = SimpleCookie()