Ticket #4338: 4338.2.diff

File 4338.2.diff, 1.0 KB (added by Gary Wilson <gary.wilson@…>, 17 years ago)

added tests

  • django/contrib/sessions/tests.py

    === added file 'django/contrib/sessions/tests.py'
     
     1r"""
     2>>> s = SessionWrapper(None)
     3
     4Inject data into the session cache.
     5>>> s._session_cache = {}
     6>>> s._session_cache['some key'] = 'exists'
     7
     8>>> s.pop('some key')
     9'exists'
     10
     11>>> s.pop('some key', 'does not exist')
     12'does not exist'
     13"""
     14
     15from django.contrib.sessions.middleware import SessionWrapper
     16
     17if __name__ == '__main__':
     18    import doctest
     19    doctest.testmod()
  • django/contrib/sessions/middleware.py

    === modified file 'django/contrib/sessions/middleware.py'
     
    3636    def get(self, key, default=None):
    3737        return self._session.get(key, default)
    3838
     39    def pop(self, key, *args):
     40        return self._session.pop(key, *args)
     41
    3942    def set_test_cookie(self):
    4043        self[TEST_COOKIE_NAME] = TEST_COOKIE_VALUE
    4144
Back to Top