1 # Simple test suite for Cookie.py
3 from test_support
import verify
5 from test_support
import verify
, verbose
7 # Currently this only tests SimpleCookie
10 ('chips=ahoy; vienna=finger', {'chips':'ahoy', 'vienna':'finger'}),
11 ('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;";',
12 {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}),
14 # Check illegal cookies that have an '=' char in an unquoted value
15 ('keebler=E=mc2;', {'keebler' : 'E=mc2'})
18 for data
, dict in cases
:
19 C
= Cookie
.SimpleCookie() ; C
.load(data
)
22 for k
, v
in dict.items():
23 print ' ', k
, repr( C
[k
].value
), repr(v
)
24 verify(C
[k
].value
== v
)
27 C
= Cookie
.SimpleCookie()
28 C
.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
30 verify(C
['Customer'].value
== 'WILE_E_COYOTE')
31 verify(C
['Customer']['version'] == '1')
32 verify(C
['Customer']['path'] == '/acme')
34 print C
.output(['path'])
36 print C
.js_output(['path'])
38 # Try cookie with quoted meta-data
39 C
= Cookie
.SimpleCookie()
40 C
.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
41 verify(C
['Customer'].value
== 'WILE_E_COYOTE')
42 verify(C
['Customer']['version'] == '1')
43 verify(C
['Customer']['path'] == '/acme')