1 # Simple test suite for Cookie.py
3 from test
.test_support
import verify
, verbose
, run_doctest
6 # Currently this only tests SimpleCookie
9 ('chips=ahoy; vienna=finger', {'chips':'ahoy', 'vienna':'finger'}),
10 ('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;";',
11 {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}),
13 # Check illegal cookies that have an '=' char in an unquoted value
14 ('keebler=E=mc2;', {'keebler' : 'E=mc2'})
17 for data
, dict in cases
:
18 C
= Cookie
.SimpleCookie() ; C
.load(data
)
24 print ' ', k
, repr( C
[k
].value
), repr(v
)
25 verify(C
[k
].value
== v
)
28 C
= Cookie
.SimpleCookie()
29 C
.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
31 verify(C
['Customer'].value
== 'WILE_E_COYOTE')
32 verify(C
['Customer']['version'] == '1')
33 verify(C
['Customer']['path'] == '/acme')
35 print C
.output(['path'])
37 print C
.js_output(['path'])
39 # Try cookie with quoted meta-data
40 C
= Cookie
.SimpleCookie()
41 C
.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
42 verify(C
['Customer'].value
== 'WILE_E_COYOTE')
43 verify(C
['Customer']['version'] == '1')
44 verify(C
['Customer']['path'] == '/acme')
46 print "If anything blows up after this line, it's from Cookie's doctest."