Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#7416 closed (fixed)

Test Client Loses session when login is called

Reported by: lakin.wecker@… Owned by: ericholscher
Component: Testing framework Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:


If data is put into the session by a view during a test, and then subsequently in the same test the client.login method is used on the test client, the client loses all session data previously in it.

It appears to be due to this line:

I quickly changed that line to:

request.session = self.session# engine.SessionStore()

Which seems more correct, but I haven't run the tests to see if it's right or not.

Attachments (2)

testclient-session.diff (589 bytes) - added by ericholscher 8 years ago.
Simple patch implementing this.
testbed.tar.bz2 (9.8 KB) - added by ericholscher 8 years ago.
A project that shows the bug.

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by ericholscher

Simple patch implementing this.

comment:1 Changed 8 years ago by ericholscher

  • Has patch set
  • milestone set to 1.0
  • Needs documentation unset
  • Needs tests set
  • Owner changed from nobody to ericholscher
  • Patch needs improvement unset
  • Status changed from new to assigned

Added a simple patch. Probably needs to be better, but this is a bug, line 56-57 in init of contrib/auth:

request.session[SESSION_KEY] =
request.session[BACKEND_SESSION_KEY] = user.backend

Sets the existing session with the user Id.

comment:2 Changed 8 years ago by ericholscher

  • Triage Stage changed from Unreviewed to Accepted

Changed 8 years ago by ericholscher

A project that shows the bug.

comment:3 Changed 8 years ago by ericholscher

Attached is a project and app that show the bug in the trunk version. The patch above fixes it. I didn't test too much more, but it appears to be working. I don't know if request.session is ever None (if it is, will that raise an error?)

comment:4 Changed 8 years ago by russellm

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [8372]) Fixed #7416: Modified test client to preserve session when a user logs in. Thanks to lakin.wecker@… for the report and Eric Holscher for the patch and test case.

comment:5 Changed 5 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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