annotate Lib/test/test_urlparse.py @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents 7ec771893410
children a742821d9e75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22474
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
1 #! /usr/bin/env python
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
24364
aa0d2d51fbde Get rid of relative imports in all unittests. Now anything that
Barry Warsaw <barry@python.org>
parents: 23075
diff changeset
3 from test import test_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
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
5 import urlparse
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"
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
9
22474
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
10 class UrlParseTestCase(unittest.TestCase):
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
11 def test_frags(self):
25812
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
12 for url, parsed, split in [
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
13 ('http://www.python.org',
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
14 ('http', 'www.python.org', '', '', '', ''),
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
15 ('http', 'www.python.org', '', '', '')),
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
16 ('http://www.python.org#abc',
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
17 ('http', 'www.python.org', '', '', '', 'abc'),
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
18 ('http', 'www.python.org', '', '', 'abc')),
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
19 ('http://www.python.org/#abc',
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
20 ('http', 'www.python.org', '/', '', '', 'abc'),
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
21 ('http', 'www.python.org', '/', '', 'abc')),
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
22 (RFC1808_BASE,
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
23 ('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
24 ('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
25 ('file:///tmp/junk.txt',
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
26 ('file', '', '/tmp/junk.txt', '', '', ''),
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
27 ('file', '', '/tmp/junk.txt', '', '')),
27100
8226658a63bb SF feature #618024, urlparse fails on imap://
Neal Norwitz <nnorwitz@gmail.com>
parents: 25812
diff changeset
28 ('imap://mail.python.org/mbox1',
8226658a63bb SF feature #618024, urlparse fails on imap://
Neal Norwitz <nnorwitz@gmail.com>
parents: 25812
diff changeset
29 ('imap', 'mail.python.org', '/mbox1', '', '', ''),
8226658a63bb SF feature #618024, urlparse fails on imap://
Neal Norwitz <nnorwitz@gmail.com>
parents: 25812
diff changeset
30 ('imap', 'mail.python.org', '/mbox1', '', '')),
27121
7ec771893410 * add mms (windows media) as another scheme
Skip Montanaro <skip@pobox.com>
parents: 27100
diff changeset
31 ('mms://wms.sys.hinet.net/cts/Drama/09006251100.asf',
7ec771893410 * add mms (windows media) as another scheme
Skip Montanaro <skip@pobox.com>
parents: 27100
diff changeset
32 ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', '', '', ''),
7ec771893410 * add mms (windows media) as another scheme
Skip Montanaro <skip@pobox.com>
parents: 27100
diff changeset
33 ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', '', '')),
25812
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
34 ]:
22474
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
35 result = urlparse.urlparse(url)
25812
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
36 self.assertEqual(result, parsed)
25425
6237be27a597 Fix SF # 591713, Fix "file:" URL to have right no. of /'s, by Bruce Atherton
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
37 # put it back together and it should be the same
6237be27a597 Fix SF # 591713, Fix "file:" URL to have right no. of /'s, by Bruce Atherton
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
38 result2 = urlparse.urlunparse(result)
6237be27a597 Fix SF # 591713, Fix "file:" URL to have right no. of /'s, by Bruce Atherton
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
39 self.assertEqual(result2, url)
22474
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
40
25812
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
41 # check the roundtrip using urlsplit() as well
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
42 result = urlparse.urlsplit(url)
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
43 self.assertEqual(result, split)
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
44 result2 = urlparse.urlunsplit(result)
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
45 self.assertEqual(result2, url)
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
46
22474
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
47 def checkJoin(self, base, relurl, expected):
25785
cf18ca0eea89 Fix for 1.33: urlsplit() should only add '//' if scheme != ''.
Guido van Rossum <guido@python.org>
parents: 25425
diff changeset
48 self.assertEqual(urlparse.urljoin(base, relurl), expected,
cf18ca0eea89 Fix for 1.33: urlsplit() should only add '//' if scheme != ''.
Guido van Rossum <guido@python.org>
parents: 25425
diff changeset
49 (base, relurl, expected))
cf18ca0eea89 Fix for 1.33: urlsplit() should only add '//' if scheme != ''.
Guido van Rossum <guido@python.org>
parents: 25425
diff changeset
50
cf18ca0eea89 Fix for 1.33: urlsplit() should only add '//' if scheme != ''.
Guido van Rossum <guido@python.org>
parents: 25425
diff changeset
51 def test_unparse_parse(self):
cf18ca0eea89 Fix for 1.33: urlsplit() should only add '//' if scheme != ''.
Guido van Rossum <guido@python.org>
parents: 25425
diff changeset
52 for u in ['Python', './Python']:
25812
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
53 self.assertEqual(urlparse.urlunsplit(urlparse.urlsplit(u)), u)
25785
cf18ca0eea89 Fix for 1.33: urlsplit() should only add '//' if scheme != ''.
Guido van Rossum <guido@python.org>
parents: 25425
diff changeset
54 self.assertEqual(urlparse.urlunparse(urlparse.urlparse(u)), u)
22379
55512fe1d6f1 amk's fix attached to
Michael W. Hudson <mwh@python.net>
parents: 15742
diff changeset
55
22474
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
56 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
57 # "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
58 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
59 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
60 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
61 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
62 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
63 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
64 self.checkJoin(RFC1808_BASE, '?y', 'http://a/b/c/d;p?y')
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
65 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
66 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
67 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
68 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
69 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
70 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
71 self.checkJoin(RFC1808_BASE, ';x', 'http://a/b/c/d;x')
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
72 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
73 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
74 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
75 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
76 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
77 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
78 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
79 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
80 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
81 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
82
22474
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
83 # "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
84 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
85 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
86 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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
98 # 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
99 # 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
100 #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
101 #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
102
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
103 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
104 # 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
105
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
106 ### urlparse.py as of v 1.32 fails on these two
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
107 #self.checkJoin(RFC2396_BASE, '?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
108 #self.checkJoin(RFC2396_BASE, ';x', 'http://a/b/c/;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
109
22474
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
110 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
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 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
119 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
120 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
121 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
122 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
123 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
124 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
125 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
126 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
127 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
128 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
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146 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
147 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
148 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
149
25812
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
150 def test_urldefrag(self):
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
151 for url, defrag, frag in [
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
152 ('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
153 ('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
154 ('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
155 ('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
156 ('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
157 ('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
158 ('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
159 ('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
160 (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
161 (RFC2396_BASE, 'http://a/b/c/d;p?q', ''),
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
162 ]:
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
163 self.assertEqual(urlparse.urldefrag(url), (defrag, frag))
5d352de94415 Make sure we test urlsplit() / urlunsplit() directly, rather than
Fred Drake <fdrake@acm.org>
parents: 25785
diff changeset
164
22474
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
165 def test_main():
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
166 test_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
167
22474
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
168 if __name__ == "__main__":
7aded6d0696e added RFC 2396 tests from Aaron Swartz included in bug # 450225.
Skip Montanaro <skip@pobox.com>
parents: 22379
diff changeset
169 test_main()