blob: 484acea0ba111128056fd55c1fb2bff12955da70 [file] [log] [blame]
Jeremy Hylton6102e292000-08-31 15:48:10 +00001# Minimal test of the quote function
2import urllib
3
4chars = 'abcdefghijklmnopqrstuvwxyz'\
5 '\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356' \
6 '\357\360\361\362\363\364\365\366\370\371\372\373\374\375\376\377' \
7 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' \
8 '\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317' \
9 '\320\321\322\323\324\325\326\330\331\332\333\334\335\336'
10
11expected = 'abcdefghijklmnopqrstuvwxyz%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f8%f9%fa%fb%fc%fd%fe%ffABCDEFGHIJKLMNOPQRSTUVWXYZ%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d8%d9%da%db%dc%dd%de'
12
13test = urllib.quote(chars)
14assert test == expected, "urllib.quote problem"
Jeremy Hylton7ae51bf2000-09-14 16:59:07 +000015test2 = urllib.unquote(expected)
16assert test2 == chars
17
18in1 = "abc/def"
19out1_1 = "abc/def"
20out1_2 = "abc%2fdef"
21
22assert urllib.quote(in1) == out1_1, "urllib.quote problem"
23assert urllib.quote(in1, '') == out1_2, "urllib.quote problem"
24
25in2 = "abc?def"
26out2_1 = "abc%3fdef"
27out2_2 = "abc?def"
28
29assert urllib.quote(in2) == out2_1, "urllib.quote problem"
30assert urllib.quote(in2, '?') == out2_2, "urllib.quote problem"
31
32