Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #13754 - Add a note about a test client session property gotcha

Thanks SmileyChris for report and patch.



git-svn-id: http://code.djangoproject.com/svn/django/trunk@13685 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 027aaca37f25d866a87a6426fa197813f75051cf 1 parent bdd13a4
@spookylukey spookylukey authored
Showing with 9 additions and 0 deletions.
  1. +9 −0 docs/topics/testing.txt
View
9 docs/topics/testing.txt
@@ -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

0 comments on commit 027aaca

Please sign in to comment.
Something went wrong with that request. Please try again.