diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2011-01-17 14:03:19 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2011-01-17 14:03:19 +0000 |
| commit | 993612c84d3c04c516486a99fa813cec1caa5488 (patch) | |
| tree | 2165f5e6ccbce0a913b12700189065449e858e7a | |
| parent | 3a9e2e90ac4d3685ada844c0e45099a6f654b39d (diff) | |
Fixed #15026 -- Added cleanup to the invalid key session tests; when using Memcached as a cache backend, the cache-backed session backends would fail on the second run due to leftover cache artefacts. Thanks to jsdalton for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15235 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/contrib/sessions/tests.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py index e8aad0f05f..9b669211db 100644 --- a/django/contrib/sessions/tests.py +++ b/django/contrib/sessions/tests.py @@ -160,11 +160,16 @@ class SessionTestsMixin(object): def test_invalid_key(self): # Submitting an invalid session key (either by guessing, or if the db has # removed the key) results in a new key being generated. - session = self.backend('1') - session.save() - self.assertNotEqual(session.session_key, '1') - self.assertEqual(session.get('cat'), None) - session.delete() + try: + session = self.backend('1') + session.save() + self.assertNotEqual(session.session_key, '1') + self.assertEqual(session.get('cat'), None) + session.delete() + finally: + # Some backends leave a stale cache entry for the invalid + # session key; make sure that entry is manually deleted + session.delete('1') # Custom session expiry def test_default_expiry(self): |
