Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_urlparse.py @ 87690:66c1c9f32567 default tip
Add use_weakref option to functools.lru_cache
The use_weakref option makes lru_cache create weak references to the function
arguments when creating the cache key, which prevents them from staying in the
memory forever even after all other references to them are gone.
This is a proof of concept for http://bugs.python.org/issue19859
| author | Radomir Dopieralski <devel@sheep.art.pl> |
|---|---|
| date | Tue, 03 Dec 2013 16:02:48 +0100 |
| parents | 472b72a61b0a |
| children |
| rev | line source |
|---|---|
|
59522
fcfe324663a6
convert shebang lines: python -> python3
Benjamin Peterson <benjamin@python.org>
parents:
58955
diff
changeset
|
1 #! /usr/bin/env python3 |
|
15742
abb94609318e
Add test cases based on RFC 1808. So now we actually have a test suite
Fred Drake <fdrake@acm.org>
parents:
13832
diff
changeset
|
2 |
|
47201
9c930a32cebb
#2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents:
44535
diff
changeset
|
3 from test import support |
|
22474
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
4 import unittest |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
5 import urllib.parse |
|
15742
abb94609318e
Add test cases based on RFC 1808. So now we actually have a test suite
Fred Drake <fdrake@acm.org>
parents:
13832
diff
changeset
|
6 |
|
abb94609318e
Add test cases based on RFC 1808. So now we actually have a test suite
Fred Drake <fdrake@acm.org>
parents:
13832
diff
changeset
|
7 RFC1808_BASE = "http://a/b/c/d;p?q#f" |
|
22474
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
8 RFC2396_BASE = "http://a/b/c/d;p?q" |
|
61357
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
9 RFC3986_BASE = 'http://a/b/c/d;p?q' |
|
63020
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
10 SIMPLE_BASE = 'http://a/b/c/d' |
|
15742
abb94609318e
Add test cases based on RFC 1808. So now we actually have a test suite
Fred Drake <fdrake@acm.org>
parents:
13832
diff
changeset
|
11 |
|
72985
e19ccbbe70dd
Remove duplication.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
71738
diff
changeset
|
12 # A list of test cases. Each test case is a two-tuple that contains |
|
48998
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
13 # a string with the query and a dictionary with the expected result. |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
14 |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
15 parse_qsl_test_cases = [ |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
16 ("", []), |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
17 ("&", []), |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
18 ("&&", []), |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
19 ("=", [('', '')]), |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
20 ("=a", [('', 'a')]), |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
21 ("a", [('a', '')]), |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
22 ("a=", [('a', '')]), |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
23 ("a=", [('a', '')]), |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
24 ("&a=b", [('a', 'b')]), |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
25 ("a=a+b&b=b+c", [('a', 'a b'), ('b', 'b c')]), |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
26 ("a=1&a=2", [('a', '1'), ('a', '2')]), |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
27 (b"", []), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
28 (b"&", []), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
29 (b"&&", []), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
30 (b"=", [(b'', b'')]), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
31 (b"=a", [(b'', b'a')]), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
32 (b"a", [(b'a', b'')]), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
33 (b"a=", [(b'a', b'')]), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
34 (b"a=", [(b'a', b'')]), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
35 (b"&a=b", [(b'a', b'b')]), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
36 (b"a=a+b&b=b+c", [(b'a', b'a b'), (b'b', b'b c')]), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
37 (b"a=1&a=2", [(b'a', b'1'), (b'a', b'2')]), |
|
48998
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
38 ] |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
39 |
|
22474
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
40 class UrlParseTestCase(unittest.TestCase): |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
41 |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
42 def checkRoundtrips(self, url, parsed, split): |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
43 result = urllib.parse.urlparse(url) |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
44 self.assertEqual(result, parsed) |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
45 t = (result.scheme, result.netloc, result.path, |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
46 result.params, result.query, result.fragment) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
47 self.assertEqual(t, parsed) |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
48 # put it back together and it should be the same |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
49 result2 = urllib.parse.urlunparse(result) |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
50 self.assertEqual(result2, url) |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
51 self.assertEqual(result2, result.geturl()) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
52 |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
53 # the result of geturl() is a fixpoint; we can always parse it |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
54 # again to get the same result: |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
55 result3 = urllib.parse.urlparse(result.geturl()) |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
56 self.assertEqual(result3.geturl(), result.geturl()) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
57 self.assertEqual(result3, result) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
58 self.assertEqual(result3.scheme, result.scheme) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
59 self.assertEqual(result3.netloc, result.netloc) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
60 self.assertEqual(result3.path, result.path) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
61 self.assertEqual(result3.params, result.params) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
62 self.assertEqual(result3.query, result.query) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
63 self.assertEqual(result3.fragment, result.fragment) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
64 self.assertEqual(result3.username, result.username) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
65 self.assertEqual(result3.password, result.password) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
66 self.assertEqual(result3.hostname, result.hostname) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
67 self.assertEqual(result3.port, result.port) |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
68 |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
69 # check the roundtrip using urlsplit() as well |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
70 result = urllib.parse.urlsplit(url) |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
71 self.assertEqual(result, split) |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
72 t = (result.scheme, result.netloc, result.path, |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
73 result.query, result.fragment) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
74 self.assertEqual(t, split) |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
75 result2 = urllib.parse.urlunsplit(result) |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
76 self.assertEqual(result2, url) |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
77 self.assertEqual(result2, result.geturl()) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
78 |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
79 # check the fixpoint property of re-parsing the result of geturl() |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
80 result3 = urllib.parse.urlsplit(result.geturl()) |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
81 self.assertEqual(result3.geturl(), result.geturl()) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
82 self.assertEqual(result3, result) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
83 self.assertEqual(result3.scheme, result.scheme) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
84 self.assertEqual(result3.netloc, result.netloc) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
85 self.assertEqual(result3.path, result.path) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
86 self.assertEqual(result3.query, result.query) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
87 self.assertEqual(result3.fragment, result.fragment) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
88 self.assertEqual(result3.username, result.username) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
89 self.assertEqual(result3.password, result.password) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
90 self.assertEqual(result3.hostname, result.hostname) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
91 self.assertEqual(result3.port, result.port) |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
92 |
|
48998
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
93 def test_qsl(self): |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
94 for orig, expect in parse_qsl_test_cases: |
|
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
95 result = urllib.parse.parse_qsl(orig, keep_blank_values=True) |
|
71470
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
96 self.assertEqual(result, expect, "Error parsing %r" % orig) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
97 expect_without_blanks = [v for v in expect if len(v[1])] |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
98 result = urllib.parse.parse_qsl(orig, keep_blank_values=False) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
99 self.assertEqual(result, expect_without_blanks, |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
100 "Error parsing %r" % orig) |
|
48998
65e23683c010
Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
Facundo Batista <facundobatista@gmail.com>
parents:
48692
diff
changeset
|
101 |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
102 def test_roundtrips(self): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
103 str_cases = [ |
|
25812
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
104 ('file:///tmp/junk.txt', |
|
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
105 ('file', '', '/tmp/junk.txt', '', '', ''), |
|
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
106 ('file', '', '/tmp/junk.txt', '', '')), |
|
27100
8226658a63bb
SF feature #618024, urlparse fails on imap://
Neal Norwitz <nnorwitz@gmail.com>
parents:
25812
diff
changeset
|
107 ('imap://mail.python.org/mbox1', |
|
8226658a63bb
SF feature #618024, urlparse fails on imap://
Neal Norwitz <nnorwitz@gmail.com>
parents:
25812
diff
changeset
|
108 ('imap', 'mail.python.org', '/mbox1', '', '', ''), |
|
8226658a63bb
SF feature #618024, urlparse fails on imap://
Neal Norwitz <nnorwitz@gmail.com>
parents:
25812
diff
changeset
|
109 ('imap', 'mail.python.org', '/mbox1', '', '')), |
|
27121
7ec771893410
* add mms (windows media) as another scheme
Skip Montanaro <skip@pobox.com>
parents:
27100
diff
changeset
|
110 ('mms://wms.sys.hinet.net/cts/Drama/09006251100.asf', |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
111 ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
112 '', '', ''), |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
113 ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
114 '', '')), |
|
52478
e9ff0efcffa9
Fix for Issue4962, issue4675.
Senthil Kumaran <orsenthil@gmail.com>
parents:
48998
diff
changeset
|
115 ('nfs://server/path/to/file.txt', |
|
e9ff0efcffa9
Fix for Issue4962, issue4675.
Senthil Kumaran <orsenthil@gmail.com>
parents:
48998
diff
changeset
|
116 ('nfs', 'server', '/path/to/file.txt', '', '', ''), |
|
e9ff0efcffa9
Fix for Issue4962, issue4675.
Senthil Kumaran <orsenthil@gmail.com>
parents:
48998
diff
changeset
|
117 ('nfs', 'server', '/path/to/file.txt', '', '')), |
|
35290
349a0fd598e0
add support for svn: and svn+ssh: URL schemes to urlparse
Fred Drake <fdrake@acm.org>
parents:
34379
diff
changeset
|
118 ('svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/', |
|
349a0fd598e0
add support for svn: and svn+ssh: URL schemes to urlparse
Fred Drake <fdrake@acm.org>
parents:
34379
diff
changeset
|
119 ('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/', |
|
349a0fd598e0
add support for svn: and svn+ssh: URL schemes to urlparse
Fred Drake <fdrake@acm.org>
parents:
34379
diff
changeset
|
120 '', '', ''), |
|
349a0fd598e0
add support for svn: and svn+ssh: URL schemes to urlparse
Fred Drake <fdrake@acm.org>
parents:
34379
diff
changeset
|
121 ('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/', |
|
61546
90a9a34e5eb5
Merged revisions 81132 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61357
diff
changeset
|
122 '', '')), |
|
90a9a34e5eb5
Merged revisions 81132 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61357
diff
changeset
|
123 ('git+ssh://git@github.com/user/project.git', |
|
90a9a34e5eb5
Merged revisions 81132 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61357
diff
changeset
|
124 ('git+ssh', 'git@github.com','/user/project.git', |
|
90a9a34e5eb5
Merged revisions 81132 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61357
diff
changeset
|
125 '','',''), |
|
90a9a34e5eb5
Merged revisions 81132 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61357
diff
changeset
|
126 ('git+ssh', 'git@github.com','/user/project.git', |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
127 '', '')), |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
128 ] |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
129 def _encode(t): |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
130 return (t[0].encode('ascii'), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
131 tuple(x.encode('ascii') for x in t[1]), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
132 tuple(x.encode('ascii') for x in t[2])) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
133 bytes_cases = [_encode(x) for x in str_cases] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
134 for url, parsed, split in str_cases + bytes_cases: |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
135 self.checkRoundtrips(url, parsed, split) |
|
22474
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
136 |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
137 def test_http_roundtrips(self): |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
138 # urllib.parse.urlsplit treats 'http:' as an optimized special case, |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
139 # so we test both 'http:' and 'https:' in all the following. |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
140 # Three cheers for white box knowledge! |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
141 str_cases = [ |
|
34379
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
142 ('://www.python.org', |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
143 ('www.python.org', '', '', '', ''), |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
144 ('www.python.org', '', '', '')), |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
145 ('://www.python.org#abc', |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
146 ('www.python.org', '', '', '', 'abc'), |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
147 ('www.python.org', '', '', 'abc')), |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
148 ('://www.python.org?q=abc', |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
149 ('www.python.org', '', '', 'q=abc', ''), |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
150 ('www.python.org', '', 'q=abc', '')), |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
151 ('://www.python.org/#abc', |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
152 ('www.python.org', '/', '', '', 'abc'), |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
153 ('www.python.org', '/', '', 'abc')), |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
154 ('://a/b/c/d;p?q#f', |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
155 ('a', '/b/c/d', 'p', 'q', 'f'), |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
156 ('a', '/b/c/d;p', 'q', 'f')), |
|
287e71f44d79
Backport patch #712317: In URLs such as http://www.example.com?query=spam,
Johannes Gijsbers <jlg@dds.nl>
parents:
30674
diff
changeset
|
157 ] |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
158 def _encode(t): |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
159 return (t[0].encode('ascii'), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
160 tuple(x.encode('ascii') for x in t[1]), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
161 tuple(x.encode('ascii') for x in t[2])) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
162 bytes_cases = [_encode(x) for x in str_cases] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
163 str_schemes = ('http', 'https') |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
164 bytes_schemes = (b'http', b'https') |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
165 str_tests = str_schemes, str_cases |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
166 bytes_tests = bytes_schemes, bytes_cases |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
167 for schemes, test_cases in (str_tests, bytes_tests): |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
168 for scheme in schemes: |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
169 for url, parsed, split in test_cases: |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
170 url = scheme + url |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
171 parsed = (scheme,) + parsed |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
172 split = (scheme,) + split |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
173 self.checkRoundtrips(url, parsed, split) |
|
25812
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
174 |
|
22474
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
175 def checkJoin(self, base, relurl, expected): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
176 str_components = (base, relurl, expected) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
177 self.assertEqual(urllib.parse.urljoin(base, relurl), expected) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
178 bytes_components = baseb, relurlb, expectedb = [ |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
179 x.encode('ascii') for x in str_components] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
180 self.assertEqual(urllib.parse.urljoin(baseb, relurlb), expectedb) |
|
25785
cf18ca0eea89
Fix for 1.33: urlsplit() should only add '//' if scheme != ''.
Guido van Rossum <guido@python.org>
parents:
25425
diff
changeset
|
181 |
|
cf18ca0eea89
Fix for 1.33: urlsplit() should only add '//' if scheme != ''.
Guido van Rossum <guido@python.org>
parents:
25425
diff
changeset
|
182 def test_unparse_parse(self): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
183 str_cases = ['Python', './Python','x-newscheme://foo.com/stuff','x://y','x:/y','x:/','/',] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
184 bytes_cases = [x.encode('ascii') for x in str_cases] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
185 for u in str_cases + bytes_cases: |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
186 self.assertEqual(urllib.parse.urlunsplit(urllib.parse.urlsplit(u)), u) |
|
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
187 self.assertEqual(urllib.parse.urlunparse(urllib.parse.urlparse(u)), u) |
| 22379 | 188 |
|
22474
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
189 def test_RFC1808(self): |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
190 # "normal" cases from RFC 1808: |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
191 self.checkJoin(RFC1808_BASE, 'g:h', 'g:h') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
192 self.checkJoin(RFC1808_BASE, 'g', 'http://a/b/c/g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
193 self.checkJoin(RFC1808_BASE, './g', 'http://a/b/c/g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
194 self.checkJoin(RFC1808_BASE, 'g/', 'http://a/b/c/g/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
195 self.checkJoin(RFC1808_BASE, '/g', 'http://a/g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
196 self.checkJoin(RFC1808_BASE, '//g', 'http://g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
197 self.checkJoin(RFC1808_BASE, 'g?y', 'http://a/b/c/g?y') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
198 self.checkJoin(RFC1808_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
199 self.checkJoin(RFC1808_BASE, '#s', 'http://a/b/c/d;p?q#s') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
200 self.checkJoin(RFC1808_BASE, 'g#s', 'http://a/b/c/g#s') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
201 self.checkJoin(RFC1808_BASE, 'g#s/./x', 'http://a/b/c/g#s/./x') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
202 self.checkJoin(RFC1808_BASE, 'g?y#s', 'http://a/b/c/g?y#s') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
203 self.checkJoin(RFC1808_BASE, 'g;x', 'http://a/b/c/g;x') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
204 self.checkJoin(RFC1808_BASE, 'g;x?y#s', 'http://a/b/c/g;x?y#s') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
205 self.checkJoin(RFC1808_BASE, '.', 'http://a/b/c/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
206 self.checkJoin(RFC1808_BASE, './', 'http://a/b/c/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
207 self.checkJoin(RFC1808_BASE, '..', 'http://a/b/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
208 self.checkJoin(RFC1808_BASE, '../', 'http://a/b/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
209 self.checkJoin(RFC1808_BASE, '../g', 'http://a/b/g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
210 self.checkJoin(RFC1808_BASE, '../..', 'http://a/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
211 self.checkJoin(RFC1808_BASE, '../../', 'http://a/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
212 self.checkJoin(RFC1808_BASE, '../../g', 'http://a/g') |
|
15742
abb94609318e
Add test cases based on RFC 1808. So now we actually have a test suite
Fred Drake <fdrake@acm.org>
parents:
13832
diff
changeset
|
213 |
|
22474
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
214 # "abnormal" cases from RFC 1808: |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
215 self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q#f') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
216 self.checkJoin(RFC1808_BASE, '../../../g', 'http://a/../g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
217 self.checkJoin(RFC1808_BASE, '../../../../g', 'http://a/../../g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
218 self.checkJoin(RFC1808_BASE, '/./g', 'http://a/./g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
219 self.checkJoin(RFC1808_BASE, '/../g', 'http://a/../g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
220 self.checkJoin(RFC1808_BASE, 'g.', 'http://a/b/c/g.') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
221 self.checkJoin(RFC1808_BASE, '.g', 'http://a/b/c/.g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
222 self.checkJoin(RFC1808_BASE, 'g..', 'http://a/b/c/g..') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
223 self.checkJoin(RFC1808_BASE, '..g', 'http://a/b/c/..g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
224 self.checkJoin(RFC1808_BASE, './../g', 'http://a/b/g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
225 self.checkJoin(RFC1808_BASE, './g/.', 'http://a/b/c/g/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
226 self.checkJoin(RFC1808_BASE, 'g/./h', 'http://a/b/c/g/h') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
227 self.checkJoin(RFC1808_BASE, 'g/../h', 'http://a/b/c/h') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
228 |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
229 # RFC 1808 and RFC 1630 disagree on these (according to RFC 1808), |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
230 # so we'll not actually run these tests (which expect 1808 behavior). |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
231 #self.checkJoin(RFC1808_BASE, 'http:g', 'http:g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
232 #self.checkJoin(RFC1808_BASE, 'http:', 'http:') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
233 |
|
69366
495d12196487
Issue #11467: Fix urlparse behavior when handling urls which contains scheme specific part only digits.
Senthil Kumaran <orsenthil@gmail.com>
parents:
66983
diff
changeset
|
234 def test_RFC2368(self): |
|
495d12196487
Issue #11467: Fix urlparse behavior when handling urls which contains scheme specific part only digits.
Senthil Kumaran <orsenthil@gmail.com>
parents:
66983
diff
changeset
|
235 # Issue 11467: path that starts with a number is not parsed correctly |
|
495d12196487
Issue #11467: Fix urlparse behavior when handling urls which contains scheme specific part only digits.
Senthil Kumaran <orsenthil@gmail.com>
parents:
66983
diff
changeset
|
236 self.assertEqual(urllib.parse.urlparse('mailto:1337@example.org'), |
|
495d12196487
Issue #11467: Fix urlparse behavior when handling urls which contains scheme specific part only digits.
Senthil Kumaran <orsenthil@gmail.com>
parents:
66983
diff
changeset
|
237 ('mailto', '', '1337@example.org', '', '', '')) |
|
495d12196487
Issue #11467: Fix urlparse behavior when handling urls which contains scheme specific part only digits.
Senthil Kumaran <orsenthil@gmail.com>
parents:
66983
diff
changeset
|
238 |
|
22474
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
239 def test_RFC2396(self): |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
240 # cases from RFC 2396 |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
241 |
|
15742
abb94609318e
Add test cases based on RFC 1808. So now we actually have a test suite
Fred Drake <fdrake@acm.org>
parents:
13832
diff
changeset
|
242 |
|
22474
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
243 self.checkJoin(RFC2396_BASE, 'g:h', 'g:h') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
244 self.checkJoin(RFC2396_BASE, 'g', 'http://a/b/c/g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
245 self.checkJoin(RFC2396_BASE, './g', 'http://a/b/c/g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
246 self.checkJoin(RFC2396_BASE, 'g/', 'http://a/b/c/g/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
247 self.checkJoin(RFC2396_BASE, '/g', 'http://a/g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
248 self.checkJoin(RFC2396_BASE, '//g', 'http://g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
249 self.checkJoin(RFC2396_BASE, 'g?y', 'http://a/b/c/g?y') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
250 self.checkJoin(RFC2396_BASE, '#s', 'http://a/b/c/d;p?q#s') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
251 self.checkJoin(RFC2396_BASE, 'g#s', 'http://a/b/c/g#s') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
252 self.checkJoin(RFC2396_BASE, 'g?y#s', 'http://a/b/c/g?y#s') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
253 self.checkJoin(RFC2396_BASE, 'g;x', 'http://a/b/c/g;x') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
254 self.checkJoin(RFC2396_BASE, 'g;x?y#s', 'http://a/b/c/g;x?y#s') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
255 self.checkJoin(RFC2396_BASE, '.', 'http://a/b/c/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
256 self.checkJoin(RFC2396_BASE, './', 'http://a/b/c/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
257 self.checkJoin(RFC2396_BASE, '..', 'http://a/b/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
258 self.checkJoin(RFC2396_BASE, '../', 'http://a/b/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
259 self.checkJoin(RFC2396_BASE, '../g', 'http://a/b/g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
260 self.checkJoin(RFC2396_BASE, '../..', 'http://a/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
261 self.checkJoin(RFC2396_BASE, '../../', 'http://a/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
262 self.checkJoin(RFC2396_BASE, '../../g', 'http://a/g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
263 self.checkJoin(RFC2396_BASE, '', RFC2396_BASE) |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
264 self.checkJoin(RFC2396_BASE, '../../../g', 'http://a/../g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
265 self.checkJoin(RFC2396_BASE, '../../../../g', 'http://a/../../g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
266 self.checkJoin(RFC2396_BASE, '/./g', 'http://a/./g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
267 self.checkJoin(RFC2396_BASE, '/../g', 'http://a/../g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
268 self.checkJoin(RFC2396_BASE, 'g.', 'http://a/b/c/g.') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
269 self.checkJoin(RFC2396_BASE, '.g', 'http://a/b/c/.g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
270 self.checkJoin(RFC2396_BASE, 'g..', 'http://a/b/c/g..') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
271 self.checkJoin(RFC2396_BASE, '..g', 'http://a/b/c/..g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
272 self.checkJoin(RFC2396_BASE, './../g', 'http://a/b/g') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
273 self.checkJoin(RFC2396_BASE, './g/.', 'http://a/b/c/g/') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
274 self.checkJoin(RFC2396_BASE, 'g/./h', 'http://a/b/c/g/h') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
275 self.checkJoin(RFC2396_BASE, 'g/../h', 'http://a/b/c/h') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
276 self.checkJoin(RFC2396_BASE, 'g;x=1/./y', 'http://a/b/c/g;x=1/y') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
277 self.checkJoin(RFC2396_BASE, 'g;x=1/../y', 'http://a/b/c/y') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
278 self.checkJoin(RFC2396_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
279 self.checkJoin(RFC2396_BASE, 'g?y/../x', 'http://a/b/c/g?y/../x') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
280 self.checkJoin(RFC2396_BASE, 'g#s/./x', 'http://a/b/c/g#s/./x') |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
281 self.checkJoin(RFC2396_BASE, 'g#s/../x', 'http://a/b/c/g#s/../x') |
|
15742
abb94609318e
Add test cases based on RFC 1808. So now we actually have a test suite
Fred Drake <fdrake@acm.org>
parents:
13832
diff
changeset
|
282 |
|
48692
293df8153f61
Issue 1432. Fixes a bug caused because of the evolution
Facundo Batista <facundobatista@gmail.com>
parents:
48444
diff
changeset
|
283 def test_RFC3986(self): |
|
61357
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
284 # Test cases from RFC3986 |
|
48692
293df8153f61
Issue 1432. Fixes a bug caused because of the evolution
Facundo Batista <facundobatista@gmail.com>
parents:
48444
diff
changeset
|
285 self.checkJoin(RFC3986_BASE, '?y','http://a/b/c/d;p?y') |
|
293df8153f61
Issue 1432. Fixes a bug caused because of the evolution
Facundo Batista <facundobatista@gmail.com>
parents:
48444
diff
changeset
|
286 self.checkJoin(RFC2396_BASE, ';x', 'http://a/b/c/;x') |
|
61357
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
287 self.checkJoin(RFC3986_BASE, 'g:h','g:h') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
288 self.checkJoin(RFC3986_BASE, 'g','http://a/b/c/g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
289 self.checkJoin(RFC3986_BASE, './g','http://a/b/c/g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
290 self.checkJoin(RFC3986_BASE, 'g/','http://a/b/c/g/') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
291 self.checkJoin(RFC3986_BASE, '/g','http://a/g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
292 self.checkJoin(RFC3986_BASE, '//g','http://g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
293 self.checkJoin(RFC3986_BASE, '?y','http://a/b/c/d;p?y') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
294 self.checkJoin(RFC3986_BASE, 'g?y','http://a/b/c/g?y') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
295 self.checkJoin(RFC3986_BASE, '#s','http://a/b/c/d;p?q#s') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
296 self.checkJoin(RFC3986_BASE, 'g#s','http://a/b/c/g#s') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
297 self.checkJoin(RFC3986_BASE, 'g?y#s','http://a/b/c/g?y#s') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
298 self.checkJoin(RFC3986_BASE, ';x','http://a/b/c/;x') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
299 self.checkJoin(RFC3986_BASE, 'g;x','http://a/b/c/g;x') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
300 self.checkJoin(RFC3986_BASE, 'g;x?y#s','http://a/b/c/g;x?y#s') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
301 self.checkJoin(RFC3986_BASE, '','http://a/b/c/d;p?q') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
302 self.checkJoin(RFC3986_BASE, '.','http://a/b/c/') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
303 self.checkJoin(RFC3986_BASE, './','http://a/b/c/') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
304 self.checkJoin(RFC3986_BASE, '..','http://a/b/') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
305 self.checkJoin(RFC3986_BASE, '../','http://a/b/') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
306 self.checkJoin(RFC3986_BASE, '../g','http://a/b/g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
307 self.checkJoin(RFC3986_BASE, '../..','http://a/') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
308 self.checkJoin(RFC3986_BASE, '../../','http://a/') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
309 self.checkJoin(RFC3986_BASE, '../../g','http://a/g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
310 |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
311 #Abnormal Examples |
|
61356
fe7e56f986cd
Merged revisions 80908 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60859
diff
changeset
|
312 |
|
61357
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
313 # The 'abnormal scenarios' are incompatible with RFC2986 parsing |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
314 # Tests are here for reference. |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
315 |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
316 #self.checkJoin(RFC3986_BASE, '../../../g','http://a/g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
317 #self.checkJoin(RFC3986_BASE, '../../../../g','http://a/g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
318 #self.checkJoin(RFC3986_BASE, '/./g','http://a/g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
319 #self.checkJoin(RFC3986_BASE, '/../g','http://a/g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
320 |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
321 self.checkJoin(RFC3986_BASE, 'g.','http://a/b/c/g.') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
322 self.checkJoin(RFC3986_BASE, '.g','http://a/b/c/.g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
323 self.checkJoin(RFC3986_BASE, 'g..','http://a/b/c/g..') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
324 self.checkJoin(RFC3986_BASE, '..g','http://a/b/c/..g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
325 self.checkJoin(RFC3986_BASE, './../g','http://a/b/g') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
326 self.checkJoin(RFC3986_BASE, './g/.','http://a/b/c/g/') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
327 self.checkJoin(RFC3986_BASE, 'g/./h','http://a/b/c/g/h') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
328 self.checkJoin(RFC3986_BASE, 'g/../h','http://a/b/c/h') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
329 self.checkJoin(RFC3986_BASE, 'g;x=1/./y','http://a/b/c/g;x=1/y') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
330 self.checkJoin(RFC3986_BASE, 'g;x=1/../y','http://a/b/c/y') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
331 self.checkJoin(RFC3986_BASE, 'g?y/./x','http://a/b/c/g?y/./x') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
332 self.checkJoin(RFC3986_BASE, 'g?y/../x','http://a/b/c/g?y/../x') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
333 self.checkJoin(RFC3986_BASE, 'g#s/./x','http://a/b/c/g#s/./x') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
334 self.checkJoin(RFC3986_BASE, 'g#s/../x','http://a/b/c/g#s/../x') |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
335 #self.checkJoin(RFC3986_BASE, 'http:g','http:g') # strict parser |
|
e3a3ed614c7e
Merged revisions 80910 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60616
diff
changeset
|
336 self.checkJoin(RFC3986_BASE, 'http:g','http://a/b/c/g') #relaxed parser |
|
48692
293df8153f61
Issue 1432. Fixes a bug caused because of the evolution
Facundo Batista <facundobatista@gmail.com>
parents:
48444
diff
changeset
|
337 |
|
66983
7a55b808e491
Merged revisions 87329 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63716
diff
changeset
|
338 # Test for issue9721 |
|
7a55b808e491
Merged revisions 87329 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63716
diff
changeset
|
339 self.checkJoin('http://a/b/c/de', ';x','http://a/b/c/;x') |
|
7a55b808e491
Merged revisions 87329 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63716
diff
changeset
|
340 |
|
63020
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
341 def test_urljoins(self): |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
342 self.checkJoin(SIMPLE_BASE, 'g:h','g:h') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
343 self.checkJoin(SIMPLE_BASE, 'http:g','http://a/b/c/g') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
344 self.checkJoin(SIMPLE_BASE, 'http:','http://a/b/c/d') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
345 self.checkJoin(SIMPLE_BASE, 'g','http://a/b/c/g') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
346 self.checkJoin(SIMPLE_BASE, './g','http://a/b/c/g') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
347 self.checkJoin(SIMPLE_BASE, 'g/','http://a/b/c/g/') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
348 self.checkJoin(SIMPLE_BASE, '/g','http://a/g') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
349 self.checkJoin(SIMPLE_BASE, '//g','http://g') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
350 self.checkJoin(SIMPLE_BASE, '?y','http://a/b/c/d?y') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
351 self.checkJoin(SIMPLE_BASE, 'g?y','http://a/b/c/g?y') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
352 self.checkJoin(SIMPLE_BASE, 'g?y/./x','http://a/b/c/g?y/./x') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
353 self.checkJoin(SIMPLE_BASE, '.','http://a/b/c/') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
354 self.checkJoin(SIMPLE_BASE, './','http://a/b/c/') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
355 self.checkJoin(SIMPLE_BASE, '..','http://a/b/') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
356 self.checkJoin(SIMPLE_BASE, '../','http://a/b/') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
357 self.checkJoin(SIMPLE_BASE, '../g','http://a/b/g') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
358 self.checkJoin(SIMPLE_BASE, '../..','http://a/') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
359 self.checkJoin(SIMPLE_BASE, '../../g','http://a/g') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
360 self.checkJoin(SIMPLE_BASE, '../../../g','http://a/../g') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
361 self.checkJoin(SIMPLE_BASE, './../g','http://a/b/g') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
362 self.checkJoin(SIMPLE_BASE, './g/.','http://a/b/c/g/') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
363 self.checkJoin(SIMPLE_BASE, '/./g','http://a/./g') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
364 self.checkJoin(SIMPLE_BASE, 'g/./h','http://a/b/c/g/h') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
365 self.checkJoin(SIMPLE_BASE, 'g/../h','http://a/b/c/h') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
366 self.checkJoin(SIMPLE_BASE, 'http:g','http://a/b/c/g') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
367 self.checkJoin(SIMPLE_BASE, 'http:','http://a/b/c/d') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
368 self.checkJoin(SIMPLE_BASE, 'http:?y','http://a/b/c/d?y') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
369 self.checkJoin(SIMPLE_BASE, 'http:g?y','http://a/b/c/g?y') |
|
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
370 self.checkJoin(SIMPLE_BASE, 'http:g?y/./x','http://a/b/c/g?y/./x') |
|
71470
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
371 self.checkJoin('http:///', '..','http:///') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
372 self.checkJoin('', 'http://a/b/c/g?y/./x','http://a/b/c/g?y/./x') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
373 self.checkJoin('', 'http://a/./g', 'http://a/./g') |
|
71730
57a836eb6916
Fix closes issue12683 - urljoin to work with relative join of svn scheme.
Senthil Kumaran <senthil@uthcode.com>
parents:
71470
diff
changeset
|
374 self.checkJoin('svn://pathtorepo/dir1', 'dir2', 'svn://pathtorepo/dir2') |
|
71738
4957131ad9dd
change the redundant svn scheme urljoin test case to svn+ssh scheme.
Senthil Kumaran <senthil@uthcode.com>
parents:
71730
diff
changeset
|
375 self.checkJoin('svn+ssh://pathtorepo/dir1', 'dir2', 'svn+ssh://pathtorepo/dir2') |
|
63020
4b456780c8d8
Merged revisions 82881 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
61546
diff
changeset
|
376 |
|
60614
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
377 def test_RFC2732(self): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
378 str_cases = [ |
|
60614
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
379 ('http://Test.python.org:5432/foo/', 'test.python.org', 5432), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
380 ('http://12.34.56.78:5432/foo/', '12.34.56.78', 5432), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
381 ('http://[::1]:5432/foo/', '::1', 5432), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
382 ('http://[dead:beef::1]:5432/foo/', 'dead:beef::1', 5432), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
383 ('http://[dead:beef::]:5432/foo/', 'dead:beef::', 5432), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
384 ('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:5432/foo/', |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
385 'dead:beef:cafe:5417:affe:8fa3:deaf:feed', 5432), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
386 ('http://[::12.34.56.78]:5432/foo/', '::12.34.56.78', 5432), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
387 ('http://[::ffff:12.34.56.78]:5432/foo/', |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
388 '::ffff:12.34.56.78', 5432), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
389 ('http://Test.python.org/foo/', 'test.python.org', None), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
390 ('http://12.34.56.78/foo/', '12.34.56.78', None), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
391 ('http://[::1]/foo/', '::1', None), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
392 ('http://[dead:beef::1]/foo/', 'dead:beef::1', None), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
393 ('http://[dead:beef::]/foo/', 'dead:beef::', None), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
394 ('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/', |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
395 'dead:beef:cafe:5417:affe:8fa3:deaf:feed', None), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
396 ('http://[::12.34.56.78]/foo/', '::12.34.56.78', None), |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
397 ('http://[::ffff:12.34.56.78]/foo/', |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
398 '::ffff:12.34.56.78', None), |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
399 ] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
400 def _encode(t): |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
401 return t[0].encode('ascii'), t[1].encode('ascii'), t[2] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
402 bytes_cases = [_encode(x) for x in str_cases] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
403 for url, hostname, port in str_cases + bytes_cases: |
|
60614
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
404 urlparsed = urllib.parse.urlparse(url) |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
405 self.assertEqual((urlparsed.hostname, urlparsed.port) , (hostname, port)) |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
406 |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
407 str_cases = [ |
|
60614
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
408 'http://::12.34.56.78]/', |
|
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
409 'http://[::1/foo/', |
|
60859
87c98fb778b4
Merged revisions 80362 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60784
diff
changeset
|
410 'ftp://[::1/foo/bad]/bad', |
|
60784
d1d209f2c803
Merged revisions 80277 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60614
diff
changeset
|
411 'http://[::1/foo/bad]/bad', |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
412 'http://[::ffff:12.34.56.78'] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
413 bytes_cases = [x.encode('ascii') for x in str_cases] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
414 for invalid_url in str_cases + bytes_cases: |
|
60859
87c98fb778b4
Merged revisions 80362 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60784
diff
changeset
|
415 self.assertRaises(ValueError, urllib.parse.urlparse, invalid_url) |
|
60614
51b85516d7f9
Merged revisions 80101 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
60538
diff
changeset
|
416 |
|
25812
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
417 def test_urldefrag(self): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
418 str_cases = [ |
|
25812
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
419 ('http://python.org#frag', 'http://python.org', 'frag'), |
|
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
420 ('http://python.org', 'http://python.org', ''), |
|
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
421 ('http://python.org/#frag', 'http://python.org/', 'frag'), |
|
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
422 ('http://python.org/', 'http://python.org/', ''), |
|
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
423 ('http://python.org/?q#frag', 'http://python.org/?q', 'frag'), |
|
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
424 ('http://python.org/?q', 'http://python.org/?q', ''), |
|
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
425 ('http://python.org/p#frag', 'http://python.org/p', 'frag'), |
|
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
426 ('http://python.org/p?q', 'http://python.org/p?q', ''), |
|
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
427 (RFC1808_BASE, 'http://a/b/c/d;p?q', 'f'), |
|
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
428 (RFC2396_BASE, 'http://a/b/c/d;p?q', ''), |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
429 ] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
430 def _encode(t): |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
431 return type(t)(x.encode('ascii') for x in t) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
432 bytes_cases = [_encode(x) for x in str_cases] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
433 for url, defrag, frag in str_cases + bytes_cases: |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
434 result = urllib.parse.urldefrag(url) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
435 self.assertEqual(result.geturl(), url) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
436 self.assertEqual(result, (defrag, frag)) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
437 self.assertEqual(result.url, defrag) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
438 self.assertEqual(result.fragment, frag) |
|
25812
5d352de94415
Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents:
25785
diff
changeset
|
439 |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
440 def test_urlsplit_attributes(self): |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
441 url = "HTTP://WWW.PYTHON.ORG/doc/#frag" |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
442 p = urllib.parse.urlsplit(url) |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
443 self.assertEqual(p.scheme, "http") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
444 self.assertEqual(p.netloc, "WWW.PYTHON.ORG") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
445 self.assertEqual(p.path, "/doc/") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
446 self.assertEqual(p.query, "") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
447 self.assertEqual(p.fragment, "frag") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
448 self.assertEqual(p.username, None) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
449 self.assertEqual(p.password, None) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
450 self.assertEqual(p.hostname, "www.python.org") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
451 self.assertEqual(p.port, None) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
452 # geturl() won't return exactly the original URL in this case |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
453 # since the scheme is always case-normalized |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
454 # We handle this by ignoring the first 4 characters of the URL |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
455 self.assertEqual(p.geturl()[4:], url[4:]) |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
456 |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
457 url = "http://User:Pass@www.python.org:080/doc/?query=yes#frag" |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
458 p = urllib.parse.urlsplit(url) |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
459 self.assertEqual(p.scheme, "http") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
460 self.assertEqual(p.netloc, "User:Pass@www.python.org:080") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
461 self.assertEqual(p.path, "/doc/") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
462 self.assertEqual(p.query, "query=yes") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
463 self.assertEqual(p.fragment, "frag") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
464 self.assertEqual(p.username, "User") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
465 self.assertEqual(p.password, "Pass") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
466 self.assertEqual(p.hostname, "www.python.org") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
467 self.assertEqual(p.port, 80) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
468 self.assertEqual(p.geturl(), url) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
469 |
|
44535
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
470 # Addressing issue1698, which suggests Username can contain |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
471 # "@" characters. Though not RFC compliant, many ftp sites allow |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
472 # and request email addresses as usernames. |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
473 |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
474 url = "http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag" |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
475 p = urllib.parse.urlsplit(url) |
|
44535
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
476 self.assertEqual(p.scheme, "http") |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
477 self.assertEqual(p.netloc, "User@example.com:Pass@www.python.org:080") |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
478 self.assertEqual(p.path, "/doc/") |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
479 self.assertEqual(p.query, "query=yes") |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
480 self.assertEqual(p.fragment, "frag") |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
481 self.assertEqual(p.username, "User@example.com") |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
482 self.assertEqual(p.password, "Pass") |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
483 self.assertEqual(p.hostname, "www.python.org") |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
484 self.assertEqual(p.port, 80) |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
485 self.assertEqual(p.geturl(), url) |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
486 |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
487 # And check them all again, only with bytes this time |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
488 url = b"HTTP://WWW.PYTHON.ORG/doc/#frag" |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
489 p = urllib.parse.urlsplit(url) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
490 self.assertEqual(p.scheme, b"http") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
491 self.assertEqual(p.netloc, b"WWW.PYTHON.ORG") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
492 self.assertEqual(p.path, b"/doc/") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
493 self.assertEqual(p.query, b"") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
494 self.assertEqual(p.fragment, b"frag") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
495 self.assertEqual(p.username, None) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
496 self.assertEqual(p.password, None) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
497 self.assertEqual(p.hostname, b"www.python.org") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
498 self.assertEqual(p.port, None) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
499 self.assertEqual(p.geturl()[4:], url[4:]) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
500 |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
501 url = b"http://User:Pass@www.python.org:080/doc/?query=yes#frag" |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
502 p = urllib.parse.urlsplit(url) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
503 self.assertEqual(p.scheme, b"http") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
504 self.assertEqual(p.netloc, b"User:Pass@www.python.org:080") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
505 self.assertEqual(p.path, b"/doc/") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
506 self.assertEqual(p.query, b"query=yes") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
507 self.assertEqual(p.fragment, b"frag") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
508 self.assertEqual(p.username, b"User") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
509 self.assertEqual(p.password, b"Pass") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
510 self.assertEqual(p.hostname, b"www.python.org") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
511 self.assertEqual(p.port, 80) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
512 self.assertEqual(p.geturl(), url) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
513 |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
514 url = b"http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag" |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
515 p = urllib.parse.urlsplit(url) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
516 self.assertEqual(p.scheme, b"http") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
517 self.assertEqual(p.netloc, b"User@example.com:Pass@www.python.org:080") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
518 self.assertEqual(p.path, b"/doc/") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
519 self.assertEqual(p.query, b"query=yes") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
520 self.assertEqual(p.fragment, b"frag") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
521 self.assertEqual(p.username, b"User@example.com") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
522 self.assertEqual(p.password, b"Pass") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
523 self.assertEqual(p.hostname, b"www.python.org") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
524 self.assertEqual(p.port, 80) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
525 self.assertEqual(p.geturl(), url) |
|
44535
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
526 |
|
77120
d769e64aed79
Issue #14036: return None when port in urlparse cross 65535
Senthil Kumaran <senthil@uthcode.com>
parents:
77052
diff
changeset
|
527 # Verify an illegal port is returned as None |
|
d769e64aed79
Issue #14036: return None when port in urlparse cross 65535
Senthil Kumaran <senthil@uthcode.com>
parents:
77052
diff
changeset
|
528 url = b"HTTP://WWW.PYTHON.ORG:65536/doc/#frag" |
|
d769e64aed79
Issue #14036: return None when port in urlparse cross 65535
Senthil Kumaran <senthil@uthcode.com>
parents:
77052
diff
changeset
|
529 p = urllib.parse.urlsplit(url) |
|
d769e64aed79
Issue #14036: return None when port in urlparse cross 65535
Senthil Kumaran <senthil@uthcode.com>
parents:
77052
diff
changeset
|
530 self.assertEqual(p.port, None) |
|
d769e64aed79
Issue #14036: return None when port in urlparse cross 65535
Senthil Kumaran <senthil@uthcode.com>
parents:
77052
diff
changeset
|
531 |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
532 def test_attributes_bad_port(self): |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
533 """Check handling of non-integer ports.""" |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
534 p = urllib.parse.urlsplit("http://www.example.net:foo") |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
535 self.assertEqual(p.netloc, "www.example.net:foo") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
536 self.assertRaises(ValueError, lambda: p.port) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
537 |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
538 p = urllib.parse.urlparse("http://www.example.net:foo") |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
539 self.assertEqual(p.netloc, "www.example.net:foo") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
540 self.assertRaises(ValueError, lambda: p.port) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
541 |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
542 # Once again, repeat ourselves to test bytes |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
543 p = urllib.parse.urlsplit(b"http://www.example.net:foo") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
544 self.assertEqual(p.netloc, b"www.example.net:foo") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
545 self.assertRaises(ValueError, lambda: p.port) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
546 |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
547 p = urllib.parse.urlparse(b"http://www.example.net:foo") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
548 self.assertEqual(p.netloc, b"www.example.net:foo") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
549 self.assertRaises(ValueError, lambda: p.port) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
550 |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
551 def test_attributes_without_netloc(self): |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
552 # This example is straight from RFC 3261. It looks like it |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
553 # should allow the username, hostname, and port to be filled |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
554 # in, but doesn't. Since it's a URI and doesn't use the |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
555 # scheme://netloc syntax, the netloc and related attributes |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
556 # should be left empty. |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
557 uri = "sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15" |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
558 p = urllib.parse.urlsplit(uri) |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
559 self.assertEqual(p.netloc, "") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
560 self.assertEqual(p.username, None) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
561 self.assertEqual(p.password, None) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
562 self.assertEqual(p.hostname, None) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
563 self.assertEqual(p.port, None) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
564 self.assertEqual(p.geturl(), uri) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
565 |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
566 p = urllib.parse.urlparse(uri) |
|
37393
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
567 self.assertEqual(p.netloc, "") |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
568 self.assertEqual(p.username, None) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
569 self.assertEqual(p.password, None) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
570 self.assertEqual(p.hostname, None) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
571 self.assertEqual(p.port, None) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
572 self.assertEqual(p.geturl(), uri) |
|
a6bce7aebe05
Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results
Fred Drake <fdrake@acm.org>
parents:
35290
diff
changeset
|
573 |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
574 # You guessed it, repeating the test with bytes input |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
575 uri = b"sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15" |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
576 p = urllib.parse.urlsplit(uri) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
577 self.assertEqual(p.netloc, b"") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
578 self.assertEqual(p.username, None) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
579 self.assertEqual(p.password, None) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
580 self.assertEqual(p.hostname, None) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
581 self.assertEqual(p.port, None) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
582 self.assertEqual(p.geturl(), uri) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
583 |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
584 p = urllib.parse.urlparse(uri) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
585 self.assertEqual(p.netloc, b"") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
586 self.assertEqual(p.username, None) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
587 self.assertEqual(p.password, None) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
588 self.assertEqual(p.hostname, None) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
589 self.assertEqual(p.port, None) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
590 self.assertEqual(p.geturl(), uri) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
591 |
|
44535
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
592 def test_noslash(self): |
|
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
593 # Issue 1637: http://foo.com?query is legal |
|
48334
5a416a6417d3
Make a new urllib package .
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
47201
diff
changeset
|
594 self.assertEqual(urllib.parse.urlparse("http://example.com?blahblah=/foo"), |
|
44535
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
595 ('http', 'example.com', '', '', 'blahblah=/foo', '')) |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
596 self.assertEqual(urllib.parse.urlparse(b"http://example.com?blahblah=/foo"), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
597 (b'http', b'example.com', b'', b'', b'blahblah=/foo', b'')) |
|
44535
420fe6d7d5f4
Merged revisions 59703-59773 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44291
diff
changeset
|
598 |
|
63716
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
599 def test_withoutscheme(self): |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
600 # Test urlparse without scheme |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
601 # Issue 754016: urlparse goes wrong with IP:port without scheme |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
602 # RFC 1808 specifies that netloc should start with //, urlparse expects |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
603 # the same, otherwise it classifies the portion of url as path. |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
604 self.assertEqual(urllib.parse.urlparse("path"), |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
605 ('','','path','','','')) |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
606 self.assertEqual(urllib.parse.urlparse("//www.python.org:80"), |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
607 ('','www.python.org:80','','','','')) |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
608 self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"), |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
609 ('http','www.python.org:80','','','','')) |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
610 # Repeat for bytes input |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
611 self.assertEqual(urllib.parse.urlparse(b"path"), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
612 (b'',b'',b'path',b'',b'',b'')) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
613 self.assertEqual(urllib.parse.urlparse(b"//www.python.org:80"), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
614 (b'',b'www.python.org:80',b'',b'',b'',b'')) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
615 self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
616 (b'http',b'www.python.org:80',b'',b'',b'',b'')) |
|
63716
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
617 |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
618 def test_portseparator(self): |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
619 # Issue 754016 makes changes for port separator ':' from scheme separator |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
620 self.assertEqual(urllib.parse.urlparse("path:80"), |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
621 ('','','path:80','','','')) |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
622 self.assertEqual(urllib.parse.urlparse("http:"),('http','','','','','')) |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
623 self.assertEqual(urllib.parse.urlparse("https:"),('https','','','','','')) |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
624 self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"), |
|
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
625 ('http','www.python.org:80','','','','')) |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
626 # As usual, need to check bytes input as well |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
627 self.assertEqual(urllib.parse.urlparse(b"path:80"), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
628 (b'',b'',b'path:80',b'',b'',b'')) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
629 self.assertEqual(urllib.parse.urlparse(b"http:"),(b'http',b'',b'',b'',b'',b'')) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
630 self.assertEqual(urllib.parse.urlparse(b"https:"),(b'https',b'',b'',b'',b'',b'')) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
631 self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
632 (b'http',b'www.python.org:80',b'',b'',b'',b'')) |
|
63716
915b028b954d
Merged revisions 83701 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63020
diff
changeset
|
633 |
|
48444
83f4b777d94c
Issue 3314. The sys module is used in an error case.
Facundo Batista <facundobatista@gmail.com>
parents:
48334
diff
changeset
|
634 def test_usingsys(self): |
|
83f4b777d94c
Issue 3314. The sys module is used in an error case.
Facundo Batista <facundobatista@gmail.com>
parents:
48334
diff
changeset
|
635 # Issue 3314: sys module is used in the error |
|
83f4b777d94c
Issue 3314. The sys module is used in an error case.
Facundo Batista <facundobatista@gmail.com>
parents:
48334
diff
changeset
|
636 self.assertRaises(TypeError, urllib.parse.urlencode, "foo") |
|
83f4b777d94c
Issue 3314. The sys module is used in an error case.
Facundo Batista <facundobatista@gmail.com>
parents:
48334
diff
changeset
|
637 |
|
58952
8b16f1408249
Merged revisions 78234 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
52478
diff
changeset
|
638 def test_anyscheme(self): |
|
8b16f1408249
Merged revisions 78234 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
52478
diff
changeset
|
639 # Issue 7904: s3://foo.com/stuff has netloc "foo.com". |
|
58955
474ec5685a2d
urllib.urlparse -> urllib.parse.urlparse
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58952
diff
changeset
|
640 self.assertEqual(urllib.parse.urlparse("s3://foo.com/stuff"), |
|
474ec5685a2d
urllib.urlparse -> urllib.parse.urlparse
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58952
diff
changeset
|
641 ('s3', 'foo.com', '/stuff', '', '', '')) |
|
474ec5685a2d
urllib.urlparse -> urllib.parse.urlparse
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58952
diff
changeset
|
642 self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff"), |
|
474ec5685a2d
urllib.urlparse -> urllib.parse.urlparse
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58952
diff
changeset
|
643 ('x-newscheme', 'foo.com', '/stuff', '', '', '')) |
|
77045
a9d43e21f7d8
Issue9374 - Generic parsing of query and fragment portion of urls for any scheme
Senthil Kumaran <senthil@uthcode.com>
parents:
75073
diff
changeset
|
644 self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query#fragment"), |
|
a9d43e21f7d8
Issue9374 - Generic parsing of query and fragment portion of urls for any scheme
Senthil Kumaran <senthil@uthcode.com>
parents:
75073
diff
changeset
|
645 ('x-newscheme', 'foo.com', '/stuff', '', 'query', 'fragment')) |
|
a9d43e21f7d8
Issue9374 - Generic parsing of query and fragment portion of urls for any scheme
Senthil Kumaran <senthil@uthcode.com>
parents:
75073
diff
changeset
|
646 self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query"), |
|
a9d43e21f7d8
Issue9374 - Generic parsing of query and fragment portion of urls for any scheme
Senthil Kumaran <senthil@uthcode.com>
parents:
75073
diff
changeset
|
647 ('x-newscheme', 'foo.com', '/stuff', '', 'query', '')) |
|
a9d43e21f7d8
Issue9374 - Generic parsing of query and fragment portion of urls for any scheme
Senthil Kumaran <senthil@uthcode.com>
parents:
75073
diff
changeset
|
648 |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
649 # And for bytes... |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
650 self.assertEqual(urllib.parse.urlparse(b"s3://foo.com/stuff"), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
651 (b's3', b'foo.com', b'/stuff', b'', b'', b'')) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
652 self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff"), |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
653 (b'x-newscheme', b'foo.com', b'/stuff', b'', b'', b'')) |
|
77045
a9d43e21f7d8
Issue9374 - Generic parsing of query and fragment portion of urls for any scheme
Senthil Kumaran <senthil@uthcode.com>
parents:
75073
diff
changeset
|
654 self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff?query#fragment"), |
|
a9d43e21f7d8
Issue9374 - Generic parsing of query and fragment portion of urls for any scheme
Senthil Kumaran <senthil@uthcode.com>
parents:
75073
diff
changeset
|
655 (b'x-newscheme', b'foo.com', b'/stuff', b'', b'query', b'fragment')) |
|
a9d43e21f7d8
Issue9374 - Generic parsing of query and fragment portion of urls for any scheme
Senthil Kumaran <senthil@uthcode.com>
parents:
75073
diff
changeset
|
656 self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff?query"), |
|
a9d43e21f7d8
Issue9374 - Generic parsing of query and fragment portion of urls for any scheme
Senthil Kumaran <senthil@uthcode.com>
parents:
75073
diff
changeset
|
657 (b'x-newscheme', b'foo.com', b'/stuff', b'', b'query', b'')) |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
658 |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
659 def test_mixed_types_rejected(self): |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
660 # Several functions that process either strings or ASCII encoded bytes |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
661 # accept multiple arguments. Check they reject mixed type input |
|
66581
38bec90fd8ab
#10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66561
diff
changeset
|
662 with self.assertRaisesRegex(TypeError, "Cannot mix str"): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
663 urllib.parse.urlparse("www.python.org", b"http") |
|
66581
38bec90fd8ab
#10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66561
diff
changeset
|
664 with self.assertRaisesRegex(TypeError, "Cannot mix str"): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
665 urllib.parse.urlparse(b"www.python.org", "http") |
|
66581
38bec90fd8ab
#10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66561
diff
changeset
|
666 with self.assertRaisesRegex(TypeError, "Cannot mix str"): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
667 urllib.parse.urlsplit("www.python.org", b"http") |
|
66581
38bec90fd8ab
#10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66561
diff
changeset
|
668 with self.assertRaisesRegex(TypeError, "Cannot mix str"): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
669 urllib.parse.urlsplit(b"www.python.org", "http") |
|
66581
38bec90fd8ab
#10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66561
diff
changeset
|
670 with self.assertRaisesRegex(TypeError, "Cannot mix str"): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
671 urllib.parse.urlunparse(( b"http", "www.python.org","","","","")) |
|
66581
38bec90fd8ab
#10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66561
diff
changeset
|
672 with self.assertRaisesRegex(TypeError, "Cannot mix str"): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
673 urllib.parse.urlunparse(("http", b"www.python.org","","","","")) |
|
66581
38bec90fd8ab
#10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66561
diff
changeset
|
674 with self.assertRaisesRegex(TypeError, "Cannot mix str"): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
675 urllib.parse.urlunsplit((b"http", "www.python.org","","","")) |
|
66581
38bec90fd8ab
#10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66561
diff
changeset
|
676 with self.assertRaisesRegex(TypeError, "Cannot mix str"): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
677 urllib.parse.urlunsplit(("http", b"www.python.org","","","")) |
|
66581
38bec90fd8ab
#10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66561
diff
changeset
|
678 with self.assertRaisesRegex(TypeError, "Cannot mix str"): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
679 urllib.parse.urljoin("http://python.org", b"http://python.org") |
|
66581
38bec90fd8ab
#10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66561
diff
changeset
|
680 with self.assertRaisesRegex(TypeError, "Cannot mix str"): |
|
66561
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
681 urllib.parse.urljoin(b"http://python.org", "http://python.org") |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
682 |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
683 def _check_result_type(self, str_type): |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
684 num_args = len(str_type._fields) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
685 bytes_type = str_type._encoded_counterpart |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
686 self.assertIs(bytes_type._decoded_counterpart, str_type) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
687 str_args = ('',) * num_args |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
688 bytes_args = (b'',) * num_args |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
689 str_result = str_type(*str_args) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
690 bytes_result = bytes_type(*bytes_args) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
691 encoding = 'ascii' |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
692 errors = 'strict' |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
693 self.assertEqual(str_result, str_args) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
694 self.assertEqual(bytes_result.decode(), str_args) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
695 self.assertEqual(bytes_result.decode(), str_result) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
696 self.assertEqual(bytes_result.decode(encoding), str_args) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
697 self.assertEqual(bytes_result.decode(encoding), str_result) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
698 self.assertEqual(bytes_result.decode(encoding, errors), str_args) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
699 self.assertEqual(bytes_result.decode(encoding, errors), str_result) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
700 self.assertEqual(bytes_result, bytes_args) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
701 self.assertEqual(str_result.encode(), bytes_args) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
702 self.assertEqual(str_result.encode(), bytes_result) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
703 self.assertEqual(str_result.encode(encoding), bytes_args) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
704 self.assertEqual(str_result.encode(encoding), bytes_result) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
705 self.assertEqual(str_result.encode(encoding, errors), bytes_args) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
706 self.assertEqual(str_result.encode(encoding, errors), bytes_result) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
707 |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
708 def test_result_pairs(self): |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
709 # Check encoding and decoding between result pairs |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
710 result_types = [ |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
711 urllib.parse.DefragResult, |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
712 urllib.parse.SplitResult, |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
713 urllib.parse.ParseResult, |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
714 ] |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
715 for result_type in result_types: |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
716 self._check_result_type(result_type) |
|
e44410e5928e
Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
Nick Coghlan <ncoghlan@gmail.com>
parents:
63715
diff
changeset
|
717 |
|
67589
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
718 def test_parse_qs_encoding(self): |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
719 result = urllib.parse.parse_qs("key=\u0141%E9", encoding="latin-1") |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
720 self.assertEqual(result, {'key': ['\u0141\xE9']}) |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
721 result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="utf-8") |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
722 self.assertEqual(result, {'key': ['\u0141\xE9']}) |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
723 result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="ascii") |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
724 self.assertEqual(result, {'key': ['\u0141\ufffd\ufffd']}) |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
725 result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii") |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
726 self.assertEqual(result, {'key': ['\u0141\ufffd-']}) |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
727 result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii", |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
728 errors="ignore") |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
729 self.assertEqual(result, {'key': ['\u0141-']}) |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
730 |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
731 def test_parse_qsl_encoding(self): |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
732 result = urllib.parse.parse_qsl("key=\u0141%E9", encoding="latin-1") |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
733 self.assertEqual(result, [('key', '\u0141\xE9')]) |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
734 result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="utf-8") |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
735 self.assertEqual(result, [('key', '\u0141\xE9')]) |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
736 result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="ascii") |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
737 self.assertEqual(result, [('key', '\u0141\ufffd\ufffd')]) |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
738 result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii") |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
739 self.assertEqual(result, [('key', '\u0141\ufffd-')]) |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
740 result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii", |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
741 errors="ignore") |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
742 self.assertEqual(result, [('key', '\u0141-')]) |
|
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
743 |
|
71470
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
744 def test_splitnport(self): |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
745 # Normal cases are exercised by other tests; ensure that we also |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
746 # catch cases with no port specified. (testcase ensuring coverage) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
747 result = urllib.parse.splitnport('parrot:88') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
748 self.assertEqual(result, ('parrot', 88)) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
749 result = urllib.parse.splitnport('parrot') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
750 self.assertEqual(result, ('parrot', -1)) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
751 result = urllib.parse.splitnport('parrot', 55) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
752 self.assertEqual(result, ('parrot', 55)) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
753 result = urllib.parse.splitnport('parrot:') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
754 self.assertEqual(result, ('parrot', None)) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
755 |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
756 def test_splitquery(self): |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
757 # Normal cases are exercised by other tests; ensure that we also |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
758 # catch cases with no port specified (testcase ensuring coverage) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
759 result = urllib.parse.splitquery('http://python.org/fake?foo=bar') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
760 self.assertEqual(result, ('http://python.org/fake', 'foo=bar')) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
761 result = urllib.parse.splitquery('http://python.org/fake?foo=bar?') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
762 self.assertEqual(result, ('http://python.org/fake?foo=bar', '')) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
763 result = urllib.parse.splitquery('http://python.org/fake') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
764 self.assertEqual(result, ('http://python.org/fake', None)) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
765 |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
766 def test_splitvalue(self): |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
767 # Normal cases are exercised by other tests; test pathological cases |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
768 # with no key/value pairs. (testcase ensuring coverage) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
769 result = urllib.parse.splitvalue('foo=bar') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
770 self.assertEqual(result, ('foo', 'bar')) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
771 result = urllib.parse.splitvalue('foo=') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
772 self.assertEqual(result, ('foo', '')) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
773 result = urllib.parse.splitvalue('foobar') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
774 self.assertEqual(result, ('foobar', None)) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
775 |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
776 def test_to_bytes(self): |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
777 result = urllib.parse.to_bytes('http://www.python.org') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
778 self.assertEqual(result, 'http://www.python.org') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
779 self.assertRaises(UnicodeError, urllib.parse.to_bytes, |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
780 'http://www.python.org/medi\u00e6val') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
781 |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
782 def test_urlencode_sequences(self): |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
783 # Other tests incidentally urlencode things; test non-covered cases: |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
784 # Sequence and object values. |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
785 result = urllib.parse.urlencode({'a': [1, 2], 'b': (3, 4, 5)}, True) |
|
75073
4a31f6b11e7a
Merge from 3.1: Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents:
72985
diff
changeset
|
786 # we cannot rely on ordering here |
|
4a31f6b11e7a
Merge from 3.1: Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents:
72985
diff
changeset
|
787 assert set(result.split('&')) == {'a=1', 'a=2', 'b=3', 'b=4', 'b=5'} |
|
71470
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
788 |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
789 class Trivial: |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
790 def __str__(self): |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
791 return 'trivial' |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
792 |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
793 result = urllib.parse.urlencode({'a': Trivial()}, True) |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
794 self.assertEqual(result, 'a=trivial') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
795 |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
796 def test_quote_from_bytes(self): |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
797 self.assertRaises(TypeError, urllib.parse.quote_from_bytes, 'foo') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
798 result = urllib.parse.quote_from_bytes(b'archaeological arcana') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
799 self.assertEqual(result, 'archaeological%20arcana') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
800 result = urllib.parse.quote_from_bytes(b'') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
801 self.assertEqual(result, '') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
802 |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
803 def test_unquote_to_bytes(self): |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
804 result = urllib.parse.unquote_to_bytes('abc%20def') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
805 self.assertEqual(result, b'abc def') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
806 result = urllib.parse.unquote_to_bytes('') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
807 self.assertEqual(result, b'') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
808 |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
809 def test_quote_errors(self): |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
810 self.assertRaises(TypeError, urllib.parse.quote, b'foo', |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
811 encoding='utf-8') |
|
e171db785c37
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
Senthil Kumaran <senthil@uthcode.com>
parents:
69367
diff
changeset
|
812 self.assertRaises(TypeError, urllib.parse.quote, b'foo', errors='strict') |
|
67589
7f8888b4fdfc
test_urlparse: add tests for encoding and errors arguments
Victor Stinner <victor.stinner@haypocalc.com>
parents:
66982
diff
changeset
|
813 |
|
77052
9f6b7576c08c
#14072: Fix parsing of tel URIs in urlparse by making the check for ports stricter.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
77045
diff
changeset
|
814 def test_issue14072(self): |
|
9f6b7576c08c
#14072: Fix parsing of tel URIs in urlparse by making the check for ports stricter.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
77045
diff
changeset
|
815 p1 = urllib.parse.urlsplit('tel:+31-641044153') |
|
9f6b7576c08c
#14072: Fix parsing of tel URIs in urlparse by making the check for ports stricter.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
77045
diff
changeset
|
816 self.assertEqual(p1.scheme, 'tel') |
|
9f6b7576c08c
#14072: Fix parsing of tel URIs in urlparse by making the check for ports stricter.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
77045
diff
changeset
|
817 self.assertEqual(p1.path, '+31-641044153') |
|
9f6b7576c08c
#14072: Fix parsing of tel URIs in urlparse by making the check for ports stricter.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
77045
diff
changeset
|
818 p2 = urllib.parse.urlsplit('tel:+31641044153') |
|
9f6b7576c08c
#14072: Fix parsing of tel URIs in urlparse by making the check for ports stricter.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
77045
diff
changeset
|
819 self.assertEqual(p2.scheme, 'tel') |
|
9f6b7576c08c
#14072: Fix parsing of tel URIs in urlparse by making the check for ports stricter.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
77045
diff
changeset
|
820 self.assertEqual(p2.path, '+31641044153') |
|
81024
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
821 # assert the behavior for urlparse |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
822 p1 = urllib.parse.urlparse('tel:+31-641044153') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
823 self.assertEqual(p1.scheme, 'tel') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
824 self.assertEqual(p1.path, '+31-641044153') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
825 p2 = urllib.parse.urlparse('tel:+31641044153') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
826 self.assertEqual(p2.scheme, 'tel') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
827 self.assertEqual(p2.path, '+31641044153') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
828 |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
829 def test_telurl_params(self): |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
830 p1 = urllib.parse.urlparse('tel:123-4;phone-context=+1-650-516') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
831 self.assertEqual(p1.scheme, 'tel') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
832 self.assertEqual(p1.path, '123-4') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
833 self.assertEqual(p1.params, 'phone-context=+1-650-516') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
834 |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
835 p1 = urllib.parse.urlparse('tel:+1-201-555-0123') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
836 self.assertEqual(p1.scheme, 'tel') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
837 self.assertEqual(p1.path, '+1-201-555-0123') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
838 self.assertEqual(p1.params, '') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
839 |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
840 p1 = urllib.parse.urlparse('tel:7042;phone-context=example.com') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
841 self.assertEqual(p1.scheme, 'tel') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
842 self.assertEqual(p1.path, '7042') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
843 self.assertEqual(p1.params, 'phone-context=example.com') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
844 |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
845 p1 = urllib.parse.urlparse('tel:863-1234;phone-context=+1-914-555') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
846 self.assertEqual(p1.scheme, 'tel') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
847 self.assertEqual(p1.path, '863-1234') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
848 self.assertEqual(p1.params, 'phone-context=+1-914-555') |
|
d002a2e46383
Fix issue16713 - tel url parsing with params
Senthil Kumaran <senthil@uthcode.com>
parents:
77120
diff
changeset
|
849 |
|
82875
472b72a61b0a
#17472: add tests for a couple of untested methods in urllib.urlparse.
R David Murray <rdmurray@bitdance.com>
parents:
81024
diff
changeset
|
850 def test_unwrap(self): |
|
472b72a61b0a
#17472: add tests for a couple of untested methods in urllib.urlparse.
R David Murray <rdmurray@bitdance.com>
parents:
81024
diff
changeset
|
851 url = urllib.parse.unwrap('<URL:type://host/path>') |
|
472b72a61b0a
#17472: add tests for a couple of untested methods in urllib.urlparse.
R David Murray <rdmurray@bitdance.com>
parents:
81024
diff
changeset
|
852 self.assertEqual(url, 'type://host/path') |
|
472b72a61b0a
#17472: add tests for a couple of untested methods in urllib.urlparse.
R David Murray <rdmurray@bitdance.com>
parents:
81024
diff
changeset
|
853 |
|
472b72a61b0a
#17472: add tests for a couple of untested methods in urllib.urlparse.
R David Murray <rdmurray@bitdance.com>
parents:
81024
diff
changeset
|
854 def test_Quoter_repr(self): |
|
472b72a61b0a
#17472: add tests for a couple of untested methods in urllib.urlparse.
R David Murray <rdmurray@bitdance.com>
parents:
81024
diff
changeset
|
855 quoter = urllib.parse.Quoter(urllib.parse._ALWAYS_SAFE) |
|
472b72a61b0a
#17472: add tests for a couple of untested methods in urllib.urlparse.
R David Murray <rdmurray@bitdance.com>
parents:
81024
diff
changeset
|
856 self.assertIn('Quoter', repr(quoter)) |
|
472b72a61b0a
#17472: add tests for a couple of untested methods in urllib.urlparse.
R David Murray <rdmurray@bitdance.com>
parents:
81024
diff
changeset
|
857 |
|
58952
8b16f1408249
Merged revisions 78234 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
52478
diff
changeset
|
858 |
|
22474
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
859 def test_main(): |
|
47201
9c930a32cebb
#2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents:
44535
diff
changeset
|
860 support.run_unittest(UrlParseTestCase) |
|
15742
abb94609318e
Add test cases based on RFC 1808. So now we actually have a test suite
Fred Drake <fdrake@acm.org>
parents:
13832
diff
changeset
|
861 |
|
22474
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
862 if __name__ == "__main__": |
|
7aded6d0696e
added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents:
22379
diff
changeset
|
863 test_main() |
