Code

Ticket #4338: 4338.2.diff

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

added tests

Line 
1=== added file 'django/contrib/sessions/tests.py'
2--- django/contrib/sessions/tests.py    1970-01-01 00:00:00 +0000
3+++ django/contrib/sessions/tests.py    2007-05-20 15:32:09 +0000
4@@ -0,0 +1,19 @@
5+r"""
6+>>> s = SessionWrapper(None)
7+
8+Inject data into the session cache.
9+>>> s._session_cache = {}
10+>>> s._session_cache['some key'] = 'exists'
11+
12+>>> s.pop('some key')
13+'exists'
14+
15+>>> s.pop('some key', 'does not exist')
16+'does not exist'
17+"""
18+
19+from django.contrib.sessions.middleware import SessionWrapper
20+
21+if __name__ == '__main__':
22+    import doctest
23+    doctest.testmod()
24
25=== modified file 'django/contrib/sessions/middleware.py'
26--- django/contrib/sessions/middleware.py       2007-03-24 01:26:21 +0000
27+++ django/contrib/sessions/middleware.py       2007-05-19 05:05:26 +0000
28@@ -36,6 +36,9 @@
29     def get(self, key, default=None):
30         return self._session.get(key, default)
31 
32+    def pop(self, key, *args):
33+        return self._session.pop(key, *args)
34+
35     def set_test_cookie(self):
36         self[TEST_COOKIE_NAME] = TEST_COOKIE_VALUE
37 
38