Opened 8 years ago

Closed 8 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: UI/UX:

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 8 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 8 years ago by Eric Holscher

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.

Changed 8 years ago by Eric Holscher

Attachment: 9788.diff added

comment:2 Changed 8 years ago by Jacob

Triage Stage: AcceptedReady for checkin

comment:3 Changed 8 years ago by Gary Wilson

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

comment:4 Changed 8 years ago by Gary Wilson

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