diff options
| author | Preston Timmons <prestontimmons@gmail.com> | 2014-05-22 17:45:02 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-05-22 20:29:48 -0400 |
| commit | be88b062afaa58559bb12623e8ed8843f07b97a1 (patch) | |
| tree | 1cff618fec57090fc73bfb40ff0b4d96a2a89dbb /django | |
| parent | 4dc4d12e27e4e0337568651136eee5b6f2171204 (diff) | |
Fixed #21357 -- Fixed test client session initialization.
The test client will now create a session when it is first accessed
if no session already exists.
Diffstat (limited to 'django')
| -rw-r--r-- | django/test/client.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/django/test/client.py b/django/test/client.py index 9513dcd809..1262e187cb 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -393,6 +393,11 @@ class Client(RequestFactory): cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None) if cookie: return engine.SessionStore(cookie.value) + else: + s = engine.SessionStore() + s.save() + self.cookies[settings.SESSION_COOKIE_NAME] = s.session_key + return s return {} session = property(_session) |
