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
)
29 print ' ', k
, repr( C
[k
].value
), repr(v
)
30 verify(C
[k
].value
== v
)
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'])
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."