Updated for 2.1b2 distribution.
[python/dscho.git] / Lib / test / test_cookie.py
blobdf592f31fd988b29e67132d4ef3a03731de15ec9
1 # Simple test suite for Cookie.py
3 from test_support import verify
4 import Cookie
5 from test_support import verify, verbose
7 # Currently this only tests SimpleCookie
9 cases = [
10 ('chips=ahoy; vienna=finger', {'chips':'ahoy', 'vienna':'finger'}),
11 ('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;";',
12 {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}),
14 # Check illegal cookies that have an '=' char in an unquoted value
15 ('keebler=E=mc2;', {'keebler' : 'E=mc2'})
18 for data, dict in cases:
19 C = Cookie.SimpleCookie() ; C.load(data)
20 print repr(C)
21 print str(C)
22 for k, v in dict.items():
23 print ' ', k, repr( C[k].value ), repr(v)
24 verify(C[k].value == v)
25 print C[k]
27 C = Cookie.SimpleCookie()
28 C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
30 verify(C['Customer'].value == 'WILE_E_COYOTE')
31 verify(C['Customer']['version'] == '1')
32 verify(C['Customer']['path'] == '/acme')
34 print C.output(['path'])
35 print C.js_output()
36 print C.js_output(['path'])
38 # Try cookie with quoted meta-data
39 C = Cookie.SimpleCookie()
40 C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
41 verify(C['Customer'].value == 'WILE_E_COYOTE')
42 verify(C['Customer']['version'] == '1')
43 verify(C['Customer']['path'] == '/acme')