title: Setting a session variable in django tests
body: <p>This works</p>
  
  <pre><code>def test_access_to_home_with_location(self):
      self.client.login(username=self.user.get_username(), password='pass')
      session = self.client.session
      session['location'] = [42]
      session.save()
      response = self.client.get(reverse('home'))
  </code></pre>
  
  <p>But this </p>
  
  <pre><code>def test_access_to_home_with_location(self):
      session = self.client.session
      session['location'] = [42]
      session.save()
      response = self.client.get(reverse('home'))
  </code></pre>
  
  <p>breaks with</p>
  
  <pre><code>====================================================================== 
  ERROR: test_access_to_home_with_location (posts.tests.HomeViewTestCase)       
  ----------------------------------------------------------------------      
  Traceback (most recent call last):                                            
    File "tests.py", line 32, in test_access_to_home_with_location                            
      session.save()                                                              
  AttributeError: 'dict' object has no attribute 'save'
  </code></pre>
  
  <p>So it seems with out calling <code>self.client.login()</code> <code>self.client.session</code> is just an empty dictionary. Is there a way to initialize it as a session object?</p>