blob: 9ae009d73a5fdba6c68cd186ffc3394b1f45fcaa [file] [log] [blame]
Andrew M. Kuchlingcdec8c72000-08-19 15:21:12 +00001
2# Simple test suite for Cookie.py
3
4import Cookie
5
6# Currently this only tests SimpleCookie
7
8cases = [
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;'}),
12 ]
13
14for data, dict in cases:
15 C = Cookie.SimpleCookie() ; C.load(data)
16 print C
17 for k, v in dict.items():
18 print ' ', k, repr( C[k].value ), repr(v)
19 assert C[k].value == v
20
21C = Cookie.SimpleCookie()
22C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
23
24assert C['Customer'].value == 'WILE_E_COYOTE'
25assert C['Customer']['version'] == '1'
26assert C['Customer']['path'] == '/acme'
Moshe Zadka514a1022000-08-19 15:57:33 +000027
28print C.output(['path'])
29print C.js_output()
30print C.js_output(['path'])
31