#11475: test.Client.session.save() raises error for anonymous users -------------------------------+-------------------------------------------- Reporter: egma...@gmail.com | Owner: nobody Status: new | Milestone: Component: Testing framework | Version: 1.1-beta-1 Keywords: | Stage: Unreviewed Has_patch: 0 | -------------------------------+-------------------------------------------- I am trying to save data into the session object for an anonymous user. While I can do this for "real" using `request.session[key] = value` I am not able to simulate this during testing (by calling `test.Client.session.save()`). A quick round of debugging revealed that the test client uses a regular dictionary object for storing session data in the case of anonymous users (as opposed to a SessionStore object for known/authenticated users). This causes an error when I try to call `self.client.session.save()` from the `setUp()` method of my test class before running a test case.
{{{ from django.test import Client, TestCase class MyTestCase(TestCase): def setUp(self): self.client = Client() self.client.session['key'] = 'value' self.client.session.save() # AttributeError: 'dict' object has no attribute 'save' def test_foo(self): self.assertEqual(1, 1) }}} I have included `django.contrib.sessions` in my `INSTALLED_APPS`. -- Ticket URL: <http://code.djangoproject.com/ticket/11475> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---