Skip to content

Commit

Permalink
[1.2.X] Fixed #13754 - Add a note about a test client session propert…
Browse files Browse the repository at this point in the history
…y gotcha

  
Thanks SmileyChris for report and patch.

Backport of [13685] from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13686 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
spookylukey committed Sep 3, 2010
1 parent 4b4168b commit 17ae1d3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/topics/testing.txt
Expand Up @@ -935,6 +935,15 @@ can access these properties as part of a test condition.
A dictionary-like object containing session information. See the
:doc:`session documentation</topics/http/sessions>` 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()

.. _Cookie module documentation: http://docs.python.org/library/cookie.html

Example
Expand Down

0 comments on commit 17ae1d3

Please sign in to comment.