Exceptions raised during renaming in rotating file handlers are now passed to handleE...
[python.git] / Lib / test / test_cookie.py
blobc20beeeb1e52558700b8b72a50722f0f7de95786
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 C.output(sep='\n')
26 for k, v in sorted(dict.iteritems()):
27 print ' ', k, repr( C[k].value ), repr(v)
28 verify(C[k].value == v)
29 print C[k]
31 C = Cookie.SimpleCookie()
32 C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
34 verify(C['Customer'].value == 'WILE_E_COYOTE')
35 verify(C['Customer']['version'] == '1')
36 verify(C['Customer']['path'] == '/acme')
38 print C.output(['path'])
39 print C.js_output()
40 print C.js_output(['path'])
42 # Try cookie with quoted meta-data
43 C = Cookie.SimpleCookie()
44 C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
45 verify(C['Customer'].value == 'WILE_E_COYOTE')
46 verify(C['Customer']['version'] == '1')
47 verify(C['Customer']['path'] == '/acme')
49 print "If anything blows up after this line, it's from Cookie's doctest."
50 run_doctest(Cookie)