Permalink
Browse files

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
  • Loading branch information...
1 parent 3a9e2e9 commit 993612c84d3c04c516486a99fa813cec1caa5488 @freakboy3742 freakboy3742 committed Jan 17, 2011
Showing with 10 additions and 5 deletions.
  1. +10 −5 django/contrib/sessions/tests.py
@@ -160,11 +160,16 @@ def test_cycle(self):
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):

0 comments on commit 993612c

Please sign in to comment.