This commit was manufactured by cvs2svn to create tag 'r211c1'.
[python/dscho.git] / Lib / test / test_cookie.py
blob2063dbfe54b42b808aeef585438de779d694887a
1 # Simple test suite for Cookie.py
3 from test_support import verify
4 import Cookie
5 from test_support import verify, verbose
6 import doctest
8 # Currently this only tests SimpleCookie
10 cases = [
11 ('chips=ahoy; vienna=finger', {'chips':'ahoy', 'vienna':'finger'}),
12 ('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;";',
13 {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}),
15 # Check illegal cookies that have an '=' char in an unquoted value
16 ('keebler=E=mc2;', {'keebler' : 'E=mc2'})
19 for data, dict in cases:
20 C = Cookie.SimpleCookie() ; C.load(data)
21 print repr(C)
22 print str(C)
23 for k, v in dict.items():
24 print ' ', k, repr( C[k].value ), repr(v)
25 verify(C[k].value == v)
26 print C[k]
28 C = Cookie.SimpleCookie()
29 C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
31 verify(C['Customer'].value == 'WILE_E_COYOTE')
32 verify(C['Customer']['version'] == '1')
33 verify(C['Customer']['path'] == '/acme')
35 print C.output(['path'])
36 print C.js_output()
37 print C.js_output(['path'])
39 # Try cookie with quoted meta-data
40 C = Cookie.SimpleCookie()
41 C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
42 verify(C['Customer'].value == 'WILE_E_COYOTE')
43 verify(C['Customer']['version'] == '1')
44 verify(C['Customer']['path'] == '/acme')
46 print "If anything blows up after this line, it's from Cookie's doctest."
47 doctest.testmod(Cookie)