diff --git a/django/test/client.py b/django/test/client.py
index dd0d811..f4b8d63 100644
|
a
|
b
|
class Client(RequestFactory):
|
| 358 | 358 | """ |
| 359 | 359 | if 'django.contrib.sessions' in settings.INSTALLED_APPS: |
| 360 | 360 | engine = import_module(settings.SESSION_ENGINE) |
| 361 | | cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None) |
| | 361 | cookie = self.cookies.get(settings.SESSION_COOKIE_NAME) |
| 362 | 362 | if cookie: |
| 363 | 363 | return engine.SessionStore(cookie.value) |
| | 364 | else: |
| | 365 | session_store = engine.SessionStore() |
| | 366 | session_store.save() |
| | 367 | self.cookies[settings.SESSION_COOKIE_NAME] = \ |
| | 368 | session_store.session_key |
| | 369 | return session_store |
| 364 | 370 | return {} |
| 365 | 371 | session = property(_session) |
| 366 | 372 | |
| 367 | | |
| 368 | 373 | def request(self, **request): |
| 369 | 374 | """ |
| 370 | 375 | The master request method. Composes the environment dictionary |
diff --git a/tests/regressiontests/test_client_regress/models.py b/tests/regressiontests/test_client_regress/models.py
index b24032d..9f415a4 100644
|
a
|
b
|
class SessionTests(TestCase):
|
| 690 | 690 | self.assertEqual(response.status_code, 200) |
| 691 | 691 | self.assertEqual(response.content, 'YES') |
| 692 | 692 | |
| | 693 | def test_session_manipulation(self): |
| | 694 | # Modify the session |
| | 695 | session = self.client.session |
| | 696 | session["session_var"] = "foo" |
| | 697 | session.save() |
| | 698 | |
| | 699 | # Check that the session works in the client |
| | 700 | response = self.client.get('/test_client_regress/check_session/') |
| | 701 | self.assertEqual(response.status_code, 200) |
| | 702 | self.assertEqual(response.content, 'foo') |
| | 703 | |
| 693 | 704 | def test_logout(self): |
| 694 | 705 | """Logout should work whether the user is logged in or not (#9978).""" |
| 695 | 706 | self.client.logout() |