﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10899	easier manipulation of sessions by test client	Rick Dean		"
Creating and modifying sessions is painful for the test client...

{{{
class SimpleTest(TestCase):
   def test_stuff(self):

      # ugly and long create of session if session doesn't exist
      from django.conf import settings
      engine = import_module(settings.SESSION_ENGINE)
      store = engine.SessionStore()
      store.save()  # we need to make load() work, or the cookie is worthless
      self.cookies[settings.SESSION_COOKIE_NAME] = store.session_key

      #   ugly and long set of session
      session = self.client.session 
      session['foo'] = 33
      session.save()

      # pretty and faster
      self.client.session['foo'] = 33

      #   ugly and long pop of session
      session = self.client.session 
      val = session.pop('foo')
      session.save()

      # pretty and faster
      val = self.client.session.pop('foo')

}}}

The attached patch makes the ""pretty and faster"" possible.
It's faster because every session get doesn't have to go
to the database.  The pretty code fails before the patch
because each fetch of self.client.session creates a new
SessionStore with a small scope, not lasting long enough
to be saved.
"	New feature	closed	Testing framework	dev	Normal	wontfix		magma.chambers@… Preston Timmons bmihelac@… Michał Łowicki Sergey Kolosov kitsunde@… deni@…	Accepted	1	0	0	1	0	0
