Jeremy Hylton | 6102e29 | 2000-08-31 15:48:10 +0000 | [diff] [blame] | 1 | # Minimal test of the quote function |
| 2 | import urllib |
| 3 | |
| 4 | chars = '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 | |
| 11 | expected = '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 | |
| 13 | test = urllib.quote(chars) |
| 14 | assert test == expected, "urllib.quote problem" |
Jeremy Hylton | 7ae51bf | 2000-09-14 16:59:07 +0000 | [diff] [blame^] | 15 | test2 = urllib.unquote(expected) |
| 16 | assert test2 == chars |
| 17 | |
| 18 | in1 = "abc/def" |
| 19 | out1_1 = "abc/def" |
| 20 | out1_2 = "abc%2fdef" |
| 21 | |
| 22 | assert urllib.quote(in1) == out1_1, "urllib.quote problem" |
| 23 | assert urllib.quote(in1, '') == out1_2, "urllib.quote problem" |
| 24 | |
| 25 | in2 = "abc?def" |
| 26 | out2_1 = "abc%3fdef" |
| 27 | out2_2 = "abc?def" |
| 28 | |
| 29 | assert urllib.quote(in2) == out2_1, "urllib.quote problem" |
| 30 | assert urllib.quote(in2, '?') == out2_2, "urllib.quote problem" |
| 31 | |
| 32 | |