_make_boundary(): Fix for SF bug #745478, broken boundary calculation
[python/dscho.git] / Lib / test / test_cookie.py
blob65b0645f2355e83574035939557153137d2c7696
1 # Simple test suite for Cookie.py
3 from test.test_support import verify, verbose, run_doctest
4 import Cookie
6 import warnings
7 warnings.filterwarnings("ignore",
8 ".* class is insecure.*",
9 DeprecationWarning)
11 # Currently this only tests SimpleCookie
13 cases = [
14 ('chips=ahoy; vienna=finger', {'chips':'ahoy', 'vienna':'finger'}),
15 ('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;";',
16 {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}),
18 # Check illegal cookies that have an '=' char in an unquoted value
19 ('keebler=E=mc2;', {'keebler' : 'E=mc2'})
22 for data, dict in cases:
23 C = Cookie.SimpleCookie() ; C.load(data)
24 print repr(C)
25 print str(C)
26 items = dict.items()
27 items.sort()
28 for k, v in items:
29 print ' ', k, repr( C[k].value ), repr(v)
30 verify(C[k].value == v)
31 print C[k]
33 C = Cookie.SimpleCookie()
34 C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
36 verify(C['Customer'].value == 'WILE_E_COYOTE')
37 verify(C['Customer']['version'] == '1')
38 verify(C['Customer']['path'] == '/acme')
40 print C.output(['path'])
41 print C.js_output()
42 print C.js_output(['path'])
44 # Try cookie with quoted meta-data
45 C = Cookie.SimpleCookie()
46 C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
47 verify(C['Customer'].value == 'WILE_E_COYOTE')
48 verify(C['Customer']['version'] == '1')
49 verify(C['Customer']['path'] == '/acme')
51 print "If anything blows up after this line, it's from Cookie's doctest."
52 run_doctest(Cookie)