test.Client.session

Client.session

A dictionary-like object containing session information. See the session documentation for full details.

To modify the session and then save it, it must be stored in a variable first (because a new SessionStore is created every time this property is accessed):

def test_something(self):
    session = self.client.session
    session['somekey'] = 'test'
    session.save()
doc_Django
2016-10-09 18:39:57
Comments
Leave a Comment

Please login to continue.