Opened 8 years ago

Closed 8 years ago

#16106 closed Bug (duplicate)

Test client session not set for unauthenticated requests

Reported by: Alexandru Plugaru Owned by: nobody
Component: Testing framework Version: 1.3
Severity: Normal Keywords: testclient
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In it says that I can do something like this in my tests:

def test_something(self):
    session = self.client.session
    session['somekey'] = 'test'

However if the client is not logged-in, self.client.session returns a dict which will result in an AttributeError.

Change History (2)

comment:1 Changed 8 years ago by Alexandru Plugaru

Summary: Test client session for unauthenticated usersTest client session not set for unauthenticated requests

I found a workaround for this bug. Just access a view that sets the session for you. For example:

session = self.client.session
session['some_var'] = 'value'

do stuff

comment:2 Changed 8 years ago by Preston Timmons

Resolution: duplicate
Status: newclosed

Thanks for the report. This issue is documented in #15740 and #10899, which has a patch to fix this. Closing this one as a duplicate.

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