diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-01-14 13:05:19 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-01-14 13:05:19 (GMT) |
commit | 1d87deb60546050f3ef3c136ae124efb96de7517 (patch) | |
tree | 10fefbd9b83468c2e65f1c782c57af025561f896 /Lib | |
parent | ac71c54b88b916e05e4279e9c4306d227f3a6dfe (diff) | |
download | cpython-1d87deb60546050f3ef3c136ae124efb96de7517.zip cpython-1d87deb60546050f3ef3c136ae124efb96de7517.tar.gz cpython-1d87deb60546050f3ef3c136ae124efb96de7517.tar.bz2 |
test_urlparse: add tests for encoding and errors arguments
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_urlparse.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index f9f97b1..628b8ec 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -688,6 +688,33 @@ class UrlParseTestCase(unittest.TestCase): for result_type in result_types: self._check_result_type(result_type) + def test_parse_qs_encoding(self): + result = urllib.parse.parse_qs("key=\u0141%E9", encoding="latin-1") + self.assertEqual(result, {'key': ['\u0141\xE9']}) + result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="utf-8") + self.assertEqual(result, {'key': ['\u0141\xE9']}) + result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="ascii") + self.assertEqual(result, {'key': ['\u0141\ufffd\ufffd']}) + result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii") + self.assertEqual(result, {'key': ['\u0141\ufffd-']}) + result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii", + errors="ignore") + self.assertEqual(result, {'key': ['\u0141-']}) + + def test_parse_qsl_encoding(self): + result = urllib.parse.parse_qsl("key=\u0141%E9", encoding="latin-1") + self.assertEqual(result, [('key', '\u0141\xE9')]) + result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="utf-8") + self.assertEqual(result, [('key', '\u0141\xE9')]) + result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="ascii") + self.assertEqual(result, [('key', '\u0141\ufffd\ufffd')]) + result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii") + self.assertEqual(result, [('key', '\u0141\ufffd-')]) + result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii", + errors="ignore") + self.assertEqual(result, [('key', '\u0141-')]) + + def test_main(): support.run_unittest(UrlParseTestCase) |