Opened 15 years ago

Closed 15 years ago

#9978 closed (fixed)

logout() method in test.client.Client raising KeyError

Reported by: Igor Sobreira Owned by: Gary Wilson
Component: Testing framework Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I've noticed this logout() method raises KeyError when I'm not authenticated.

I'm not sure it's a bug, but in my opinion it should fail silently. Catch the exception would solve it.

[1] http://code.djangoproject.com/browser/django/trunk/django/test/client.py#L413

Attachments (1)

9788.diff (2.2 KB ) - added by Eric Holscher 15 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Eric Holscher, 15 years ago

Owner: changed from nobody to Eric Holscher
Triage Stage: UnreviewedAccepted

This is indeed a problem. If you log in and then log out, logout() doesn't cause an error. Only when you have never logged in and try to log out.

Attached is a simple testcase and a one line fix to the logout() function simple checking to see if that key exists before trying to delete it.

by Eric Holscher, 15 years ago

Attachment: 9788.diff added

comment:2 by Jacob, 15 years ago

Triage Stage: AcceptedReady for checkin

comment:3 by Gary Wilson, 15 years ago

Owner: changed from Eric Holscher to Gary Wilson
Status: newassigned

comment:4 by Gary Wilson, 15 years ago

Resolution: fixed
Status: assignedclosed

(In [10228]) 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.

Note: See TracTickets for help on using tickets.
Back to Top