Skip to content

Commit

Permalink
Fixed #15026 -- Added cleanup to the invalid key session tests; when …
Browse files Browse the repository at this point in the history
…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
freakboy3742 committed Jan 17, 2011
1 parent 3a9e2e9 commit 993612c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions django/contrib/sessions/tests.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -160,11 +160,16 @@ def test_cycle(self):
def test_invalid_key(self): def test_invalid_key(self):
# Submitting an invalid session key (either by guessing, or if the db has # Submitting an invalid session key (either by guessing, or if the db has
# removed the key) results in a new key being generated. # removed the key) results in a new key being generated.
session = self.backend('1') try:
session.save() session = self.backend('1')
self.assertNotEqual(session.session_key, '1') session.save()
self.assertEqual(session.get('cat'), None) self.assertNotEqual(session.session_key, '1')
session.delete() 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 # Custom session expiry
def test_default_expiry(self): def test_default_expiry(self):
Expand Down

0 comments on commit 993612c

Please sign in to comment.