Opened 13 years ago
Closed 13 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 |
Description
In https://docs.djangoproject.com/en/1.3/topics/testing/#django.test.client.Client.session it says that I can do something like this in my tests:
def test_something(self): session = self.client.session session['somekey'] = 'test' session.save()
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 by , 13 years ago
Summary: | Test client session for unauthenticated users → Test client session not set for unauthenticated requests |
---|
comment:2 by , 13 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
I found a workaround for this bug. Just access a view that sets the session for you. For example: