Ticket #15026: cleanup_session_records_after_invalid_key_test.diff

File cleanup_session_records_after_invalid_key_test.diff, 1.0 KB (added by jsdalton, 4 years ago)
  • django/contrib/sessions/tests.py

     
    160160    def test_invalid_key(self):
    161161        # Submitting an invalid session key (either by guessing, or if the db has
    162162        # removed the key) results in a new key being generated.
    163         session = self.backend('1')
    164         session.save()
    165         self.assertNotEqual(session.session_key, '1')
    166         self.assertEqual(session.get('cat'), None)
    167         session.delete()
     163        try:
     164            session = self.backend('1')
     165            session.save()
     166            self.assertNotEqual(session.session_key, '1')
     167            self.assertEqual(session.get('cat'), None)
     168        finally:
     169            # Be sure to clean up both session records that are now stored in the backend
     170            session.delete()
     171            session.delete('1')
    168172
    169173    # Custom session expiry
    170174    def test_default_expiry(self):
Back to Top