1 # Simple test suite for Cookie.py
3 from test
.test_support
import verify
, verbose
, run_doctest
7 warnings
.filterwarnings("ignore",
8 ".* class is insecure.*",
11 # Currently this only tests SimpleCookie
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
)
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
)
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'])
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."