2010-03-11 18:53:45 -04:00
|
|
|
#! /usr/bin/env python3
|
2001-01-05 01:57:04 -04:00
|
|
|
|
2008-05-20 18:35:26 -03:00
|
|
|
from test import support
|
2002-03-23 01:32:10 -04:00
|
|
|
import unittest
|
2008-06-18 17:49:58 -03:00
|
|
|
import urllib.parse
|
2001-01-05 01:57:04 -04:00
|
|
|
|
|
|
|
RFC1808_BASE = "http://a/b/c/d;p?q#f"
|
2002-03-23 01:32:10 -04:00
|
|
|
RFC2396_BASE = "http://a/b/c/d;p?q"
|
2010-05-07 01:19:23 -03:00
|
|
|
RFC3986_BASE = 'http://a/b/c/d;p?q'
|
2010-07-14 07:21:22 -03:00
|
|
|
SIMPLE_BASE = 'http://a/b/c/d'
|
2002-03-23 01:32:10 -04:00
|
|
|
|
2011-10-19 04:58:56 -03:00
|
|
|
# A list of test cases. Each test case is a two-tuple that contains
|
2008-09-03 19:49:01 -03:00
|
|
|
# a string with the query and a dictionary with the expected result.
|
|
|
|
|
|
|
|
parse_qsl_test_cases = [
|
|
|
|
("", []),
|
|
|
|
("&", []),
|
|
|
|
("&&", []),
|
|
|
|
("=", [('', '')]),
|
|
|
|
("=a", [('', 'a')]),
|
|
|
|
("a", [('a', '')]),
|
|
|
|
("a=", [('a', '')]),
|
|
|
|
("a=", [('a', '')]),
|
|
|
|
("&a=b", [('a', 'b')]),
|
|
|
|
("a=a+b&b=b+c", [('a', 'a b'), ('b', 'b c')]),
|
|
|
|
("a=1&a=2", [('a', '1'), ('a', '2')]),
|
2010-11-30 11:48:08 -04:00
|
|
|
(b"", []),
|
|
|
|
(b"&", []),
|
|
|
|
(b"&&", []),
|
|
|
|
(b"=", [(b'', b'')]),
|
|
|
|
(b"=a", [(b'', b'a')]),
|
|
|
|
(b"a", [(b'a', b'')]),
|
|
|
|
(b"a=", [(b'a', b'')]),
|
|
|
|
(b"a=", [(b'a', b'')]),
|
|
|
|
(b"&a=b", [(b'a', b'b')]),
|
|
|
|
(b"a=a+b&b=b+c", [(b'a', b'a b'), (b'b', b'b c')]),
|
|
|
|
(b"a=1&a=2", [(b'a', b'1'), (b'a', b'2')]),
|
2008-09-03 19:49:01 -03:00
|
|
|
]
|
|
|
|
|
2002-03-23 01:32:10 -04:00
|
|
|
class UrlParseTestCase(unittest.TestCase):
|
2005-01-09 11:29:10 -04:00
|
|
|
|
|
|
|
def checkRoundtrips(self, url, parsed, split):
|
2008-06-18 17:49:58 -03:00
|
|
|
result = urllib.parse.urlparse(url)
|
2005-01-09 11:29:10 -04:00
|
|
|
self.assertEqual(result, parsed)
|
2006-04-21 07:40:58 -03:00
|
|
|
t = (result.scheme, result.netloc, result.path,
|
|
|
|
result.params, result.query, result.fragment)
|
|
|
|
self.assertEqual(t, parsed)
|
2005-01-09 11:29:10 -04:00
|
|
|
# put it back together and it should be the same
|
2008-06-18 17:49:58 -03:00
|
|
|
result2 = urllib.parse.urlunparse(result)
|
2005-01-09 11:29:10 -04:00
|
|
|
self.assertEqual(result2, url)
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(result2, result.geturl())
|
|
|
|
|
|
|
|
# the result of geturl() is a fixpoint; we can always parse it
|
|
|
|
# again to get the same result:
|
2008-06-18 17:49:58 -03:00
|
|
|
result3 = urllib.parse.urlparse(result.geturl())
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(result3.geturl(), result.geturl())
|
|
|
|
self.assertEqual(result3, result)
|
|
|
|
self.assertEqual(result3.scheme, result.scheme)
|
|
|
|
self.assertEqual(result3.netloc, result.netloc)
|
|
|
|
self.assertEqual(result3.path, result.path)
|
|
|
|
self.assertEqual(result3.params, result.params)
|
|
|
|
self.assertEqual(result3.query, result.query)
|
|
|
|
self.assertEqual(result3.fragment, result.fragment)
|
|
|
|
self.assertEqual(result3.username, result.username)
|
|
|
|
self.assertEqual(result3.password, result.password)
|
|
|
|
self.assertEqual(result3.hostname, result.hostname)
|
|
|
|
self.assertEqual(result3.port, result.port)
|
2005-01-09 11:29:10 -04:00
|
|
|
|
|
|
|
# check the roundtrip using urlsplit() as well
|
2008-06-18 17:49:58 -03:00
|
|
|
result = urllib.parse.urlsplit(url)
|
2005-01-09 11:29:10 -04:00
|
|
|
self.assertEqual(result, split)
|
2006-04-21 07:40:58 -03:00
|
|
|
t = (result.scheme, result.netloc, result.path,
|
|
|
|
result.query, result.fragment)
|
|
|
|
self.assertEqual(t, split)
|
2008-06-18 17:49:58 -03:00
|
|
|
result2 = urllib.parse.urlunsplit(result)
|
2005-01-09 11:29:10 -04:00
|
|
|
self.assertEqual(result2, url)
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(result2, result.geturl())
|
|
|
|
|
|
|
|
# check the fixpoint property of re-parsing the result of geturl()
|
2008-06-18 17:49:58 -03:00
|
|
|
result3 = urllib.parse.urlsplit(result.geturl())
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(result3.geturl(), result.geturl())
|
|
|
|
self.assertEqual(result3, result)
|
|
|
|
self.assertEqual(result3.scheme, result.scheme)
|
|
|
|
self.assertEqual(result3.netloc, result.netloc)
|
|
|
|
self.assertEqual(result3.path, result.path)
|
|
|
|
self.assertEqual(result3.query, result.query)
|
|
|
|
self.assertEqual(result3.fragment, result.fragment)
|
|
|
|
self.assertEqual(result3.username, result.username)
|
|
|
|
self.assertEqual(result3.password, result.password)
|
|
|
|
self.assertEqual(result3.hostname, result.hostname)
|
|
|
|
self.assertEqual(result3.port, result.port)
|
2005-01-09 11:29:10 -04:00
|
|
|
|
2008-09-03 19:49:01 -03:00
|
|
|
def test_qsl(self):
|
|
|
|
for orig, expect in parse_qsl_test_cases:
|
|
|
|
result = urllib.parse.parse_qsl(orig, keep_blank_values=True)
|
2011-07-23 07:27:45 -03:00
|
|
|
self.assertEqual(result, expect, "Error parsing %r" % orig)
|
|
|
|
expect_without_blanks = [v for v in expect if len(v[1])]
|
|
|
|
result = urllib.parse.parse_qsl(orig, keep_blank_values=False)
|
|
|
|
self.assertEqual(result, expect_without_blanks,
|
|
|
|
"Error parsing %r" % orig)
|
2008-09-03 19:49:01 -03:00
|
|
|
|
2005-01-09 11:29:10 -04:00
|
|
|
def test_roundtrips(self):
|
2010-11-30 11:48:08 -04:00
|
|
|
str_cases = [
|
2002-10-16 18:02:36 -03:00
|
|
|
('file:///tmp/junk.txt',
|
|
|
|
('file', '', '/tmp/junk.txt', '', '', ''),
|
|
|
|
('file', '', '/tmp/junk.txt', '', '')),
|
2003-01-06 02:58:31 -04:00
|
|
|
('imap://mail.python.org/mbox1',
|
|
|
|
('imap', 'mail.python.org', '/mbox1', '', '', ''),
|
|
|
|
('imap', 'mail.python.org', '/mbox1', '', '')),
|
2003-01-06 16:27:03 -04:00
|
|
|
('mms://wms.sys.hinet.net/cts/Drama/09006251100.asf',
|
2005-01-09 11:29:10 -04:00
|
|
|
('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf',
|
|
|
|
'', '', ''),
|
|
|
|
('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf',
|
|
|
|
'', '')),
|
2009-03-30 18:54:41 -03:00
|
|
|
('nfs://server/path/to/file.txt',
|
|
|
|
('nfs', 'server', '/path/to/file.txt', '', '', ''),
|
|
|
|
('nfs', 'server', '/path/to/file.txt', '', '')),
|
2005-07-29 12:56:32 -03:00
|
|
|
('svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/',
|
|
|
|
('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/',
|
|
|
|
'', '', ''),
|
|
|
|
('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/',
|
2010-05-13 00:37:23 -03:00
|
|
|
'', '')),
|
|
|
|
('git+ssh://git@github.com/user/project.git',
|
|
|
|
('git+ssh', 'git@github.com','/user/project.git',
|
|
|
|
'','',''),
|
|
|
|
('git+ssh', 'git@github.com','/user/project.git',
|
2010-11-30 11:48:08 -04:00
|
|
|
'', '')),
|
2005-01-09 11:29:10 -04:00
|
|
|
]
|
2010-11-30 11:48:08 -04:00
|
|
|
def _encode(t):
|
|
|
|
return (t[0].encode('ascii'),
|
|
|
|
tuple(x.encode('ascii') for x in t[1]),
|
|
|
|
tuple(x.encode('ascii') for x in t[2]))
|
|
|
|
bytes_cases = [_encode(x) for x in str_cases]
|
|
|
|
for url, parsed, split in str_cases + bytes_cases:
|
2005-01-09 11:29:10 -04:00
|
|
|
self.checkRoundtrips(url, parsed, split)
|
|
|
|
|
|
|
|
def test_http_roundtrips(self):
|
2008-06-18 17:49:58 -03:00
|
|
|
# urllib.parse.urlsplit treats 'http:' as an optimized special case,
|
2005-01-09 11:29:10 -04:00
|
|
|
# so we test both 'http:' and 'https:' in all the following.
|
|
|
|
# Three cheers for white box knowledge!
|
2010-11-30 11:48:08 -04:00
|
|
|
str_cases = [
|
2005-01-09 11:29:10 -04:00
|
|
|
('://www.python.org',
|
|
|
|
('www.python.org', '', '', '', ''),
|
|
|
|
('www.python.org', '', '', '')),
|
|
|
|
('://www.python.org#abc',
|
|
|
|
('www.python.org', '', '', '', 'abc'),
|
|
|
|
('www.python.org', '', '', 'abc')),
|
|
|
|
('://www.python.org?q=abc',
|
|
|
|
('www.python.org', '', '', 'q=abc', ''),
|
|
|
|
('www.python.org', '', 'q=abc', '')),
|
|
|
|
('://www.python.org/#abc',
|
|
|
|
('www.python.org', '/', '', '', 'abc'),
|
|
|
|
('www.python.org', '/', '', 'abc')),
|
|
|
|
('://a/b/c/d;p?q#f',
|
|
|
|
('a', '/b/c/d', 'p', 'q', 'f'),
|
|
|
|
('a', '/b/c/d;p', 'q', 'f')),
|
|
|
|
]
|
2010-11-30 11:48:08 -04:00
|
|
|
def _encode(t):
|
|
|
|
return (t[0].encode('ascii'),
|
|
|
|
tuple(x.encode('ascii') for x in t[1]),
|
|
|
|
tuple(x.encode('ascii') for x in t[2]))
|
|
|
|
bytes_cases = [_encode(x) for x in str_cases]
|
|
|
|
str_schemes = ('http', 'https')
|
|
|
|
bytes_schemes = (b'http', b'https')
|
|
|
|
str_tests = str_schemes, str_cases
|
|
|
|
bytes_tests = bytes_schemes, bytes_cases
|
|
|
|
for schemes, test_cases in (str_tests, bytes_tests):
|
|
|
|
for scheme in schemes:
|
|
|
|
for url, parsed, split in test_cases:
|
|
|
|
url = scheme + url
|
|
|
|
parsed = (scheme,) + parsed
|
|
|
|
split = (scheme,) + split
|
|
|
|
self.checkRoundtrips(url, parsed, split)
|
2002-10-16 18:02:36 -03:00
|
|
|
|
2002-03-23 01:32:10 -04:00
|
|
|
def checkJoin(self, base, relurl, expected):
|
2010-11-30 11:48:08 -04:00
|
|
|
str_components = (base, relurl, expected)
|
|
|
|
self.assertEqual(urllib.parse.urljoin(base, relurl), expected)
|
|
|
|
bytes_components = baseb, relurlb, expectedb = [
|
|
|
|
x.encode('ascii') for x in str_components]
|
|
|
|
self.assertEqual(urllib.parse.urljoin(baseb, relurlb), expectedb)
|
2002-10-14 16:59:54 -03:00
|
|
|
|
|
|
|
def test_unparse_parse(self):
|
2010-11-30 11:48:08 -04:00
|
|
|
str_cases = ['Python', './Python','x-newscheme://foo.com/stuff','x://y','x:/y','x:/','/',]
|
|
|
|
bytes_cases = [x.encode('ascii') for x in str_cases]
|
|
|
|
for u in str_cases + bytes_cases:
|
2008-06-18 17:49:58 -03:00
|
|
|
self.assertEqual(urllib.parse.urlunsplit(urllib.parse.urlsplit(u)), u)
|
|
|
|
self.assertEqual(urllib.parse.urlunparse(urllib.parse.urlparse(u)), u)
|
2002-03-23 01:32:10 -04:00
|
|
|
|
|
|
|
def test_RFC1808(self):
|
|
|
|
# "normal" cases from RFC 1808:
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g:h', 'g:h')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g', 'http://a/b/c/g')
|
|
|
|
self.checkJoin(RFC1808_BASE, './g', 'http://a/b/c/g')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g/', 'http://a/b/c/g/')
|
|
|
|
self.checkJoin(RFC1808_BASE, '/g', 'http://a/g')
|
|
|
|
self.checkJoin(RFC1808_BASE, '//g', 'http://g')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g?y', 'http://a/b/c/g?y')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x')
|
|
|
|
self.checkJoin(RFC1808_BASE, '#s', 'http://a/b/c/d;p?q#s')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g#s', 'http://a/b/c/g#s')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g#s/./x', 'http://a/b/c/g#s/./x')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g?y#s', 'http://a/b/c/g?y#s')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g;x', 'http://a/b/c/g;x')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g;x?y#s', 'http://a/b/c/g;x?y#s')
|
|
|
|
self.checkJoin(RFC1808_BASE, '.', 'http://a/b/c/')
|
|
|
|
self.checkJoin(RFC1808_BASE, './', 'http://a/b/c/')
|
|
|
|
self.checkJoin(RFC1808_BASE, '..', 'http://a/b/')
|
|
|
|
self.checkJoin(RFC1808_BASE, '../', 'http://a/b/')
|
|
|
|
self.checkJoin(RFC1808_BASE, '../g', 'http://a/b/g')
|
|
|
|
self.checkJoin(RFC1808_BASE, '../..', 'http://a/')
|
|
|
|
self.checkJoin(RFC1808_BASE, '../../', 'http://a/')
|
|
|
|
self.checkJoin(RFC1808_BASE, '../../g', 'http://a/g')
|
|
|
|
|
|
|
|
# "abnormal" cases from RFC 1808:
|
|
|
|
self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q#f')
|
|
|
|
self.checkJoin(RFC1808_BASE, '../../../g', 'http://a/../g')
|
|
|
|
self.checkJoin(RFC1808_BASE, '../../../../g', 'http://a/../../g')
|
|
|
|
self.checkJoin(RFC1808_BASE, '/./g', 'http://a/./g')
|
|
|
|
self.checkJoin(RFC1808_BASE, '/../g', 'http://a/../g')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g.', 'http://a/b/c/g.')
|
|
|
|
self.checkJoin(RFC1808_BASE, '.g', 'http://a/b/c/.g')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g..', 'http://a/b/c/g..')
|
|
|
|
self.checkJoin(RFC1808_BASE, '..g', 'http://a/b/c/..g')
|
|
|
|
self.checkJoin(RFC1808_BASE, './../g', 'http://a/b/g')
|
|
|
|
self.checkJoin(RFC1808_BASE, './g/.', 'http://a/b/c/g/')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g/./h', 'http://a/b/c/g/h')
|
|
|
|
self.checkJoin(RFC1808_BASE, 'g/../h', 'http://a/b/c/h')
|
2001-01-05 01:57:04 -04:00
|
|
|
|
2002-03-23 01:32:10 -04:00
|
|
|
# RFC 1808 and RFC 1630 disagree on these (according to RFC 1808),
|
|
|
|
# so we'll not actually run these tests (which expect 1808 behavior).
|
|
|
|
#self.checkJoin(RFC1808_BASE, 'http:g', 'http:g')
|
|
|
|
#self.checkJoin(RFC1808_BASE, 'http:', 'http:')
|
2002-03-18 09:06:00 -04:00
|
|
|
|
2011-04-15 07:20:24 -03:00
|
|
|
def test_RFC2368(self):
|
|
|
|
# Issue 11467: path that starts with a number is not parsed correctly
|
|
|
|
self.assertEqual(urllib.parse.urlparse('mailto:1337@example.org'),
|
|
|
|
('mailto', '', '1337@example.org', '', '', ''))
|
|
|
|
|
2002-03-23 01:32:10 -04:00
|
|
|
def test_RFC2396(self):
|
|
|
|
# cases from RFC 2396
|
2001-01-05 01:57:04 -04:00
|
|
|
|
|
|
|
|
2002-03-23 01:32:10 -04:00
|
|
|
self.checkJoin(RFC2396_BASE, 'g:h', 'g:h')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g', 'http://a/b/c/g')
|
|
|
|
self.checkJoin(RFC2396_BASE, './g', 'http://a/b/c/g')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g/', 'http://a/b/c/g/')
|
|
|
|
self.checkJoin(RFC2396_BASE, '/g', 'http://a/g')
|
|
|
|
self.checkJoin(RFC2396_BASE, '//g', 'http://g')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g?y', 'http://a/b/c/g?y')
|
|
|
|
self.checkJoin(RFC2396_BASE, '#s', 'http://a/b/c/d;p?q#s')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g#s', 'http://a/b/c/g#s')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g?y#s', 'http://a/b/c/g?y#s')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g;x', 'http://a/b/c/g;x')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g;x?y#s', 'http://a/b/c/g;x?y#s')
|
|
|
|
self.checkJoin(RFC2396_BASE, '.', 'http://a/b/c/')
|
|
|
|
self.checkJoin(RFC2396_BASE, './', 'http://a/b/c/')
|
|
|
|
self.checkJoin(RFC2396_BASE, '..', 'http://a/b/')
|
|
|
|
self.checkJoin(RFC2396_BASE, '../', 'http://a/b/')
|
|
|
|
self.checkJoin(RFC2396_BASE, '../g', 'http://a/b/g')
|
|
|
|
self.checkJoin(RFC2396_BASE, '../..', 'http://a/')
|
|
|
|
self.checkJoin(RFC2396_BASE, '../../', 'http://a/')
|
|
|
|
self.checkJoin(RFC2396_BASE, '../../g', 'http://a/g')
|
|
|
|
self.checkJoin(RFC2396_BASE, '', RFC2396_BASE)
|
|
|
|
self.checkJoin(RFC2396_BASE, '../../../g', 'http://a/../g')
|
|
|
|
self.checkJoin(RFC2396_BASE, '../../../../g', 'http://a/../../g')
|
|
|
|
self.checkJoin(RFC2396_BASE, '/./g', 'http://a/./g')
|
|
|
|
self.checkJoin(RFC2396_BASE, '/../g', 'http://a/../g')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g.', 'http://a/b/c/g.')
|
|
|
|
self.checkJoin(RFC2396_BASE, '.g', 'http://a/b/c/.g')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g..', 'http://a/b/c/g..')
|
|
|
|
self.checkJoin(RFC2396_BASE, '..g', 'http://a/b/c/..g')
|
|
|
|
self.checkJoin(RFC2396_BASE, './../g', 'http://a/b/g')
|
|
|
|
self.checkJoin(RFC2396_BASE, './g/.', 'http://a/b/c/g/')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g/./h', 'http://a/b/c/g/h')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g/../h', 'http://a/b/c/h')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g;x=1/./y', 'http://a/b/c/g;x=1/y')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g;x=1/../y', 'http://a/b/c/y')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g?y/../x', 'http://a/b/c/g?y/../x')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g#s/./x', 'http://a/b/c/g#s/./x')
|
|
|
|
self.checkJoin(RFC2396_BASE, 'g#s/../x', 'http://a/b/c/g#s/../x')
|
2001-01-05 01:57:04 -04:00
|
|
|
|
2008-08-14 13:55:14 -03:00
|
|
|
def test_RFC3986(self):
|
2010-05-07 01:19:23 -03:00
|
|
|
# Test cases from RFC3986
|
2008-08-14 13:55:14 -03:00
|
|
|
self.checkJoin(RFC3986_BASE, '?y','http://a/b/c/d;p?y')
|
|
|
|
self.checkJoin(RFC2396_BASE, ';x', 'http://a/b/c/;x')
|
2010-05-07 01:19:23 -03:00
|
|
|
self.checkJoin(RFC3986_BASE, 'g:h','g:h')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g','http://a/b/c/g')
|
|
|
|
self.checkJoin(RFC3986_BASE, './g','http://a/b/c/g')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g/','http://a/b/c/g/')
|
|
|
|
self.checkJoin(RFC3986_BASE, '/g','http://a/g')
|
|
|
|
self.checkJoin(RFC3986_BASE, '//g','http://g')
|
|
|
|
self.checkJoin(RFC3986_BASE, '?y','http://a/b/c/d;p?y')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g?y','http://a/b/c/g?y')
|
|
|
|
self.checkJoin(RFC3986_BASE, '#s','http://a/b/c/d;p?q#s')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g#s','http://a/b/c/g#s')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g?y#s','http://a/b/c/g?y#s')
|
|
|
|
self.checkJoin(RFC3986_BASE, ';x','http://a/b/c/;x')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g;x','http://a/b/c/g;x')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g;x?y#s','http://a/b/c/g;x?y#s')
|
|
|
|
self.checkJoin(RFC3986_BASE, '','http://a/b/c/d;p?q')
|
|
|
|
self.checkJoin(RFC3986_BASE, '.','http://a/b/c/')
|
|
|
|
self.checkJoin(RFC3986_BASE, './','http://a/b/c/')
|
|
|
|
self.checkJoin(RFC3986_BASE, '..','http://a/b/')
|
|
|
|
self.checkJoin(RFC3986_BASE, '../','http://a/b/')
|
|
|
|
self.checkJoin(RFC3986_BASE, '../g','http://a/b/g')
|
|
|
|
self.checkJoin(RFC3986_BASE, '../..','http://a/')
|
|
|
|
self.checkJoin(RFC3986_BASE, '../../','http://a/')
|
|
|
|
self.checkJoin(RFC3986_BASE, '../../g','http://a/g')
|
|
|
|
|
|
|
|
#Abnormal Examples
|
|
|
|
|
|
|
|
# The 'abnormal scenarios' are incompatible with RFC2986 parsing
|
|
|
|
# Tests are here for reference.
|
|
|
|
|
|
|
|
#self.checkJoin(RFC3986_BASE, '../../../g','http://a/g')
|
|
|
|
#self.checkJoin(RFC3986_BASE, '../../../../g','http://a/g')
|
|
|
|
#self.checkJoin(RFC3986_BASE, '/./g','http://a/g')
|
|
|
|
#self.checkJoin(RFC3986_BASE, '/../g','http://a/g')
|
|
|
|
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g.','http://a/b/c/g.')
|
|
|
|
self.checkJoin(RFC3986_BASE, '.g','http://a/b/c/.g')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g..','http://a/b/c/g..')
|
|
|
|
self.checkJoin(RFC3986_BASE, '..g','http://a/b/c/..g')
|
|
|
|
self.checkJoin(RFC3986_BASE, './../g','http://a/b/g')
|
|
|
|
self.checkJoin(RFC3986_BASE, './g/.','http://a/b/c/g/')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g/./h','http://a/b/c/g/h')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g/../h','http://a/b/c/h')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g;x=1/./y','http://a/b/c/g;x=1/y')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g;x=1/../y','http://a/b/c/y')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g?y/./x','http://a/b/c/g?y/./x')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g?y/../x','http://a/b/c/g?y/../x')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g#s/./x','http://a/b/c/g#s/./x')
|
|
|
|
self.checkJoin(RFC3986_BASE, 'g#s/../x','http://a/b/c/g#s/../x')
|
|
|
|
#self.checkJoin(RFC3986_BASE, 'http:g','http:g') # strict parser
|
|
|
|
self.checkJoin(RFC3986_BASE, 'http:g','http://a/b/c/g') #relaxed parser
|
2008-08-14 13:55:14 -03:00
|
|
|
|
2010-12-17 00:48:45 -04:00
|
|
|
# Test for issue9721
|
|
|
|
self.checkJoin('http://a/b/c/de', ';x','http://a/b/c/;x')
|
|
|
|
|
2010-07-14 07:21:22 -03:00
|
|
|
def test_urljoins(self):
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'g:h','g:h')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'http:g','http://a/b/c/g')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'http:','http://a/b/c/d')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'g','http://a/b/c/g')
|
|
|
|
self.checkJoin(SIMPLE_BASE, './g','http://a/b/c/g')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'g/','http://a/b/c/g/')
|
|
|
|
self.checkJoin(SIMPLE_BASE, '/g','http://a/g')
|
|
|
|
self.checkJoin(SIMPLE_BASE, '//g','http://g')
|
|
|
|
self.checkJoin(SIMPLE_BASE, '?y','http://a/b/c/d?y')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'g?y','http://a/b/c/g?y')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'g?y/./x','http://a/b/c/g?y/./x')
|
|
|
|
self.checkJoin(SIMPLE_BASE, '.','http://a/b/c/')
|
|
|
|
self.checkJoin(SIMPLE_BASE, './','http://a/b/c/')
|
|
|
|
self.checkJoin(SIMPLE_BASE, '..','http://a/b/')
|
|
|
|
self.checkJoin(SIMPLE_BASE, '../','http://a/b/')
|
|
|
|
self.checkJoin(SIMPLE_BASE, '../g','http://a/b/g')
|
|
|
|
self.checkJoin(SIMPLE_BASE, '../..','http://a/')
|
|
|
|
self.checkJoin(SIMPLE_BASE, '../../g','http://a/g')
|
|
|
|
self.checkJoin(SIMPLE_BASE, '../../../g','http://a/../g')
|
|
|
|
self.checkJoin(SIMPLE_BASE, './../g','http://a/b/g')
|
|
|
|
self.checkJoin(SIMPLE_BASE, './g/.','http://a/b/c/g/')
|
|
|
|
self.checkJoin(SIMPLE_BASE, '/./g','http://a/./g')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'g/./h','http://a/b/c/g/h')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'g/../h','http://a/b/c/h')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'http:g','http://a/b/c/g')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'http:','http://a/b/c/d')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'http:?y','http://a/b/c/d?y')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'http:g?y','http://a/b/c/g?y')
|
|
|
|
self.checkJoin(SIMPLE_BASE, 'http:g?y/./x','http://a/b/c/g?y/./x')
|
2011-07-23 07:27:45 -03:00
|
|
|
self.checkJoin('http:///', '..','http:///')
|
|
|
|
self.checkJoin('', 'http://a/b/c/g?y/./x','http://a/b/c/g?y/./x')
|
|
|
|
self.checkJoin('', 'http://a/./g', 'http://a/./g')
|
2011-08-03 07:37:22 -03:00
|
|
|
self.checkJoin('svn://pathtorepo/dir1', 'dir2', 'svn://pathtorepo/dir2')
|
2011-08-03 11:08:46 -03:00
|
|
|
self.checkJoin('svn+ssh://pathtorepo/dir1', 'dir2', 'svn+ssh://pathtorepo/dir2')
|
2010-07-14 07:21:22 -03:00
|
|
|
|
2010-04-16 00:02:13 -03:00
|
|
|
def test_RFC2732(self):
|
2010-11-30 11:48:08 -04:00
|
|
|
str_cases = [
|
2010-04-16 00:02:13 -03:00
|
|
|
('http://Test.python.org:5432/foo/', 'test.python.org', 5432),
|
|
|
|
('http://12.34.56.78:5432/foo/', '12.34.56.78', 5432),
|
|
|
|
('http://[::1]:5432/foo/', '::1', 5432),
|
|
|
|
('http://[dead:beef::1]:5432/foo/', 'dead:beef::1', 5432),
|
|
|
|
('http://[dead:beef::]:5432/foo/', 'dead:beef::', 5432),
|
|
|
|
('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:5432/foo/',
|
|
|
|
'dead:beef:cafe:5417:affe:8fa3:deaf:feed', 5432),
|
|
|
|
('http://[::12.34.56.78]:5432/foo/', '::12.34.56.78', 5432),
|
|
|
|
('http://[::ffff:12.34.56.78]:5432/foo/',
|
|
|
|
'::ffff:12.34.56.78', 5432),
|
|
|
|
('http://Test.python.org/foo/', 'test.python.org', None),
|
|
|
|
('http://12.34.56.78/foo/', '12.34.56.78', None),
|
|
|
|
('http://[::1]/foo/', '::1', None),
|
|
|
|
('http://[dead:beef::1]/foo/', 'dead:beef::1', None),
|
|
|
|
('http://[dead:beef::]/foo/', 'dead:beef::', None),
|
|
|
|
('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/',
|
|
|
|
'dead:beef:cafe:5417:affe:8fa3:deaf:feed', None),
|
|
|
|
('http://[::12.34.56.78]/foo/', '::12.34.56.78', None),
|
|
|
|
('http://[::ffff:12.34.56.78]/foo/',
|
|
|
|
'::ffff:12.34.56.78', None),
|
2010-11-30 11:48:08 -04:00
|
|
|
]
|
|
|
|
def _encode(t):
|
|
|
|
return t[0].encode('ascii'), t[1].encode('ascii'), t[2]
|
|
|
|
bytes_cases = [_encode(x) for x in str_cases]
|
|
|
|
for url, hostname, port in str_cases + bytes_cases:
|
2010-04-16 00:02:13 -03:00
|
|
|
urlparsed = urllib.parse.urlparse(url)
|
|
|
|
self.assertEqual((urlparsed.hostname, urlparsed.port) , (hostname, port))
|
|
|
|
|
2010-11-30 11:48:08 -04:00
|
|
|
str_cases = [
|
2010-04-16 00:02:13 -03:00
|
|
|
'http://::12.34.56.78]/',
|
|
|
|
'http://[::1/foo/',
|
2010-04-22 09:19:46 -03:00
|
|
|
'ftp://[::1/foo/bad]/bad',
|
2010-04-20 17:42:50 -03:00
|
|
|
'http://[::1/foo/bad]/bad',
|
2010-11-30 11:48:08 -04:00
|
|
|
'http://[::ffff:12.34.56.78']
|
|
|
|
bytes_cases = [x.encode('ascii') for x in str_cases]
|
|
|
|
for invalid_url in str_cases + bytes_cases:
|
2010-04-22 09:19:46 -03:00
|
|
|
self.assertRaises(ValueError, urllib.parse.urlparse, invalid_url)
|
2010-04-16 00:02:13 -03:00
|
|
|
|
2002-10-16 18:02:36 -03:00
|
|
|
def test_urldefrag(self):
|
2010-11-30 11:48:08 -04:00
|
|
|
str_cases = [
|
2002-10-16 18:02:36 -03:00
|
|
|
('http://python.org#frag', 'http://python.org', 'frag'),
|
|
|
|
('http://python.org', 'http://python.org', ''),
|
|
|
|
('http://python.org/#frag', 'http://python.org/', 'frag'),
|
|
|
|
('http://python.org/', 'http://python.org/', ''),
|
|
|
|
('http://python.org/?q#frag', 'http://python.org/?q', 'frag'),
|
|
|
|
('http://python.org/?q', 'http://python.org/?q', ''),
|
|
|
|
('http://python.org/p#frag', 'http://python.org/p', 'frag'),
|
|
|
|
('http://python.org/p?q', 'http://python.org/p?q', ''),
|
|
|
|
(RFC1808_BASE, 'http://a/b/c/d;p?q', 'f'),
|
|
|
|
(RFC2396_BASE, 'http://a/b/c/d;p?q', ''),
|
2010-11-30 11:48:08 -04:00
|
|
|
]
|
|
|
|
def _encode(t):
|
|
|
|
return type(t)(x.encode('ascii') for x in t)
|
|
|
|
bytes_cases = [_encode(x) for x in str_cases]
|
|
|
|
for url, defrag, frag in str_cases + bytes_cases:
|
|
|
|
result = urllib.parse.urldefrag(url)
|
|
|
|
self.assertEqual(result.geturl(), url)
|
|
|
|
self.assertEqual(result, (defrag, frag))
|
|
|
|
self.assertEqual(result.url, defrag)
|
|
|
|
self.assertEqual(result.fragment, frag)
|
2002-10-16 18:02:36 -03:00
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
def test_urlsplit_attributes(self):
|
|
|
|
url = "HTTP://WWW.PYTHON.ORG/doc/#frag"
|
2008-06-18 17:49:58 -03:00
|
|
|
p = urllib.parse.urlsplit(url)
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(p.scheme, "http")
|
|
|
|
self.assertEqual(p.netloc, "WWW.PYTHON.ORG")
|
|
|
|
self.assertEqual(p.path, "/doc/")
|
|
|
|
self.assertEqual(p.query, "")
|
|
|
|
self.assertEqual(p.fragment, "frag")
|
|
|
|
self.assertEqual(p.username, None)
|
|
|
|
self.assertEqual(p.password, None)
|
|
|
|
self.assertEqual(p.hostname, "www.python.org")
|
|
|
|
self.assertEqual(p.port, None)
|
|
|
|
# geturl() won't return exactly the original URL in this case
|
|
|
|
# since the scheme is always case-normalized
|
2010-11-30 11:48:08 -04:00
|
|
|
# We handle this by ignoring the first 4 characters of the URL
|
|
|
|
self.assertEqual(p.geturl()[4:], url[4:])
|
2006-04-21 07:40:58 -03:00
|
|
|
|
|
|
|
url = "http://User:Pass@www.python.org:080/doc/?query=yes#frag"
|
2008-06-18 17:49:58 -03:00
|
|
|
p = urllib.parse.urlsplit(url)
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(p.scheme, "http")
|
|
|
|
self.assertEqual(p.netloc, "User:Pass@www.python.org:080")
|
|
|
|
self.assertEqual(p.path, "/doc/")
|
|
|
|
self.assertEqual(p.query, "query=yes")
|
|
|
|
self.assertEqual(p.fragment, "frag")
|
|
|
|
self.assertEqual(p.username, "User")
|
|
|
|
self.assertEqual(p.password, "Pass")
|
|
|
|
self.assertEqual(p.hostname, "www.python.org")
|
|
|
|
self.assertEqual(p.port, 80)
|
|
|
|
self.assertEqual(p.geturl(), url)
|
|
|
|
|
Merged revisions 59703-59773 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59704 | christian.heimes | 2008-01-04 04:15:05 +0100 (Fri, 04 Jan 2008) | 1 line
Moved include "Python.h" in front of other imports to silence a warning.
........
r59706 | raymond.hettinger | 2008-01-04 04:22:53 +0100 (Fri, 04 Jan 2008) | 10 lines
Minor fix-ups to named tuples:
* Make the _replace() method respect subclassing.
* Using property() to make _fields read-only wasn't a good idea.
It caused len(Point._fields) to fail.
* Add note to _cast() about length checking and alternative with the star-operator.
........
r59707 | jeffrey.yasskin | 2008-01-04 09:01:23 +0100 (Fri, 04 Jan 2008) | 3 lines
Make math.{floor,ceil}({int,long}) return float again for backwards
compatibility after r59671 made them return integral types.
........
r59709 | christian.heimes | 2008-01-04 14:21:07 +0100 (Fri, 04 Jan 2008) | 1 line
Bug #1713: posixpath.ismount() claims symlink to a mountpoint is a mountpoint.
........
r59712 | lars.gustaebel | 2008-01-04 15:00:33 +0100 (Fri, 04 Jan 2008) | 5 lines
Issue #1735: TarFile.extractall() now correctly sets
directory permissions and times.
(will backport to 2.5)
........
r59714 | andrew.kuchling | 2008-01-04 15:47:17 +0100 (Fri, 04 Jan 2008) | 1 line
Update links to bug/patch tracker
........
r59716 | christian.heimes | 2008-01-04 16:23:30 +0100 (Fri, 04 Jan 2008) | 1 line
Added interface to Windows' WSAIoctl and a simple example for a network sniffer.
........
r59717 | christian.heimes | 2008-01-04 16:29:00 +0100 (Fri, 04 Jan 2008) | 1 line
And here is the rest of Hirokazu Yamamoto's patch for VS6.0 support. Thanks Hiro!
........
r59719 | christian.heimes | 2008-01-04 16:34:06 +0100 (Fri, 04 Jan 2008) | 1 line
Reverted last transaction. It's the wrong branch.
........
r59721 | christian.heimes | 2008-01-04 16:48:06 +0100 (Fri, 04 Jan 2008) | 1 line
socket.ioctl is only available on Windows
........
r59722 | andrew.kuchling | 2008-01-04 19:24:41 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59723 | andrew.kuchling | 2008-01-04 19:25:05 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59725 | guido.van.rossum | 2008-01-05 01:59:59 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1725 by Mark Dickinson, fixes incorrect conversion of -1e1000
and adds errors for -0x.
........
r59726 | guido.van.rossum | 2008-01-05 02:21:57 +0100 (Sat, 05 Jan 2008) | 2 lines
Patch #1698 by Senthil: allow '@' in username when parsed by urlparse.py.
........
r59727 | raymond.hettinger | 2008-01-05 02:35:43 +0100 (Sat, 05 Jan 2008) | 1 line
Improve namedtuple's _cast() method with a docstring, new name, and error-checking.
........
r59728 | raymond.hettinger | 2008-01-05 03:17:24 +0100 (Sat, 05 Jan 2008) | 1 line
Add error-checking to namedtuple's _replace() method.
........
r59730 | fred.drake | 2008-01-05 05:38:38 +0100 (Sat, 05 Jan 2008) | 2 lines
clean up a comment
........
r59731 | jeffrey.yasskin | 2008-01-05 09:47:13 +0100 (Sat, 05 Jan 2008) | 11 lines
Continue rolling back pep-3141 changes that changed behavior from 2.5. This
round included:
* Revert round to its 2.6 behavior (half away from 0).
* Because round, floor, and ceil always return float again, it's no
longer necessary to have them delegate to __xxx___, so I've ripped
that out of their implementations and the Real ABC. This also helps
in implementing types that work in both 2.6 and 3.0: you return int
from the __xxx__ methods, and let it get enabled by the version
upgrade.
* Make pow(-1, .5) raise a ValueError again.
........
r59736 | andrew.kuchling | 2008-01-05 16:13:49 +0100 (Sat, 05 Jan 2008) | 1 line
Fix comment typo
........
r59738 | thomas.heller | 2008-01-05 18:15:44 +0100 (Sat, 05 Jan 2008) | 1 line
Add myself.
........
r59739 | georg.brandl | 2008-01-05 18:49:17 +0100 (Sat, 05 Jan 2008) | 2 lines
Fix C++-style comment.
........
r59742 | georg.brandl | 2008-01-05 20:28:16 +0100 (Sat, 05 Jan 2008) | 2 lines
Remove with_statement future imports from 2.6 docs.
........
r59743 | georg.brandl | 2008-01-05 20:29:45 +0100 (Sat, 05 Jan 2008) | 2 lines
Simplify index entries; fix #1712.
........
r59744 | georg.brandl | 2008-01-05 20:44:22 +0100 (Sat, 05 Jan 2008) | 2 lines
Doc patch #1730 from Robin Stocker; minor corrections mostly to os.rst.
........
r59749 | georg.brandl | 2008-01-05 21:29:13 +0100 (Sat, 05 Jan 2008) | 2 lines
Revert socket.rst to unix-eol.
........
r59750 | georg.brandl | 2008-01-05 21:33:46 +0100 (Sat, 05 Jan 2008) | 2 lines
Set native svn:eol-style property for text files.
........
r59752 | georg.brandl | 2008-01-05 21:46:29 +0100 (Sat, 05 Jan 2008) | 2 lines
#1719: capitalization error in "UuidCreate".
........
r59753 | georg.brandl | 2008-01-05 22:02:25 +0100 (Sat, 05 Jan 2008) | 2 lines
Repair markup.
........
r59754 | georg.brandl | 2008-01-05 22:10:50 +0100 (Sat, 05 Jan 2008) | 2 lines
Use markup.
........
r59757 | christian.heimes | 2008-01-05 22:35:52 +0100 (Sat, 05 Jan 2008) | 1 line
Final adjustments for #1601
........
r59758 | guido.van.rossum | 2008-01-05 23:19:06 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
Fix by John Nagle.
........
r59759 | guido.van.rossum | 2008-01-05 23:20:01 +0100 (Sat, 05 Jan 2008) | 2 lines
Add John Nagle (of issue #1637).
........
r59765 | raymond.hettinger | 2008-01-06 10:02:24 +0100 (Sun, 06 Jan 2008) | 1 line
Small code simplification. Forgot that classmethods can be called from intances.
........
r59766 | martin.v.loewis | 2008-01-06 11:09:48 +0100 (Sun, 06 Jan 2008) | 2 lines
Use vcbuild for VS 2009.
........
r59767 | martin.v.loewis | 2008-01-06 12:03:43 +0100 (Sun, 06 Jan 2008) | 2 lines
Package using VS 2008.
........
r59768 | martin.v.loewis | 2008-01-06 12:13:16 +0100 (Sun, 06 Jan 2008) | 2 lines
Don't try to package msvcr90 for the moment.
........
r59769 | georg.brandl | 2008-01-06 15:17:36 +0100 (Sun, 06 Jan 2008) | 4 lines
#1696393: don't check for '.' and '..' in ntpath.walk since
they aren't returned from os.listdir anymore.
Reported by Michael Haggerty.
........
r59770 | georg.brandl | 2008-01-06 15:27:15 +0100 (Sun, 06 Jan 2008) | 3 lines
#1742: don't raise exception on os.path.relpath("a", "a"), but return os.curdir.
Reported by Jesse Towner.
........
r59771 | georg.brandl | 2008-01-06 15:33:52 +0100 (Sun, 06 Jan 2008) | 2 lines
#1591: Clarify docstring of Popen3.
........
r59772 | georg.brandl | 2008-01-06 16:30:34 +0100 (Sun, 06 Jan 2008) | 2 lines
#1680: fix context manager example function name.
........
r59773 | georg.brandl | 2008-01-06 16:34:57 +0100 (Sun, 06 Jan 2008) | 2 lines
#1755097: document default values for [].sort() and sorted().
........
2008-01-06 12:59:19 -04:00
|
|
|
# Addressing issue1698, which suggests Username can contain
|
|
|
|
# "@" characters. Though not RFC compliant, many ftp sites allow
|
|
|
|
# and request email addresses as usernames.
|
|
|
|
|
|
|
|
url = "http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag"
|
2008-06-18 17:49:58 -03:00
|
|
|
p = urllib.parse.urlsplit(url)
|
Merged revisions 59703-59773 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59704 | christian.heimes | 2008-01-04 04:15:05 +0100 (Fri, 04 Jan 2008) | 1 line
Moved include "Python.h" in front of other imports to silence a warning.
........
r59706 | raymond.hettinger | 2008-01-04 04:22:53 +0100 (Fri, 04 Jan 2008) | 10 lines
Minor fix-ups to named tuples:
* Make the _replace() method respect subclassing.
* Using property() to make _fields read-only wasn't a good idea.
It caused len(Point._fields) to fail.
* Add note to _cast() about length checking and alternative with the star-operator.
........
r59707 | jeffrey.yasskin | 2008-01-04 09:01:23 +0100 (Fri, 04 Jan 2008) | 3 lines
Make math.{floor,ceil}({int,long}) return float again for backwards
compatibility after r59671 made them return integral types.
........
r59709 | christian.heimes | 2008-01-04 14:21:07 +0100 (Fri, 04 Jan 2008) | 1 line
Bug #1713: posixpath.ismount() claims symlink to a mountpoint is a mountpoint.
........
r59712 | lars.gustaebel | 2008-01-04 15:00:33 +0100 (Fri, 04 Jan 2008) | 5 lines
Issue #1735: TarFile.extractall() now correctly sets
directory permissions and times.
(will backport to 2.5)
........
r59714 | andrew.kuchling | 2008-01-04 15:47:17 +0100 (Fri, 04 Jan 2008) | 1 line
Update links to bug/patch tracker
........
r59716 | christian.heimes | 2008-01-04 16:23:30 +0100 (Fri, 04 Jan 2008) | 1 line
Added interface to Windows' WSAIoctl and a simple example for a network sniffer.
........
r59717 | christian.heimes | 2008-01-04 16:29:00 +0100 (Fri, 04 Jan 2008) | 1 line
And here is the rest of Hirokazu Yamamoto's patch for VS6.0 support. Thanks Hiro!
........
r59719 | christian.heimes | 2008-01-04 16:34:06 +0100 (Fri, 04 Jan 2008) | 1 line
Reverted last transaction. It's the wrong branch.
........
r59721 | christian.heimes | 2008-01-04 16:48:06 +0100 (Fri, 04 Jan 2008) | 1 line
socket.ioctl is only available on Windows
........
r59722 | andrew.kuchling | 2008-01-04 19:24:41 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59723 | andrew.kuchling | 2008-01-04 19:25:05 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59725 | guido.van.rossum | 2008-01-05 01:59:59 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1725 by Mark Dickinson, fixes incorrect conversion of -1e1000
and adds errors for -0x.
........
r59726 | guido.van.rossum | 2008-01-05 02:21:57 +0100 (Sat, 05 Jan 2008) | 2 lines
Patch #1698 by Senthil: allow '@' in username when parsed by urlparse.py.
........
r59727 | raymond.hettinger | 2008-01-05 02:35:43 +0100 (Sat, 05 Jan 2008) | 1 line
Improve namedtuple's _cast() method with a docstring, new name, and error-checking.
........
r59728 | raymond.hettinger | 2008-01-05 03:17:24 +0100 (Sat, 05 Jan 2008) | 1 line
Add error-checking to namedtuple's _replace() method.
........
r59730 | fred.drake | 2008-01-05 05:38:38 +0100 (Sat, 05 Jan 2008) | 2 lines
clean up a comment
........
r59731 | jeffrey.yasskin | 2008-01-05 09:47:13 +0100 (Sat, 05 Jan 2008) | 11 lines
Continue rolling back pep-3141 changes that changed behavior from 2.5. This
round included:
* Revert round to its 2.6 behavior (half away from 0).
* Because round, floor, and ceil always return float again, it's no
longer necessary to have them delegate to __xxx___, so I've ripped
that out of their implementations and the Real ABC. This also helps
in implementing types that work in both 2.6 and 3.0: you return int
from the __xxx__ methods, and let it get enabled by the version
upgrade.
* Make pow(-1, .5) raise a ValueError again.
........
r59736 | andrew.kuchling | 2008-01-05 16:13:49 +0100 (Sat, 05 Jan 2008) | 1 line
Fix comment typo
........
r59738 | thomas.heller | 2008-01-05 18:15:44 +0100 (Sat, 05 Jan 2008) | 1 line
Add myself.
........
r59739 | georg.brandl | 2008-01-05 18:49:17 +0100 (Sat, 05 Jan 2008) | 2 lines
Fix C++-style comment.
........
r59742 | georg.brandl | 2008-01-05 20:28:16 +0100 (Sat, 05 Jan 2008) | 2 lines
Remove with_statement future imports from 2.6 docs.
........
r59743 | georg.brandl | 2008-01-05 20:29:45 +0100 (Sat, 05 Jan 2008) | 2 lines
Simplify index entries; fix #1712.
........
r59744 | georg.brandl | 2008-01-05 20:44:22 +0100 (Sat, 05 Jan 2008) | 2 lines
Doc patch #1730 from Robin Stocker; minor corrections mostly to os.rst.
........
r59749 | georg.brandl | 2008-01-05 21:29:13 +0100 (Sat, 05 Jan 2008) | 2 lines
Revert socket.rst to unix-eol.
........
r59750 | georg.brandl | 2008-01-05 21:33:46 +0100 (Sat, 05 Jan 2008) | 2 lines
Set native svn:eol-style property for text files.
........
r59752 | georg.brandl | 2008-01-05 21:46:29 +0100 (Sat, 05 Jan 2008) | 2 lines
#1719: capitalization error in "UuidCreate".
........
r59753 | georg.brandl | 2008-01-05 22:02:25 +0100 (Sat, 05 Jan 2008) | 2 lines
Repair markup.
........
r59754 | georg.brandl | 2008-01-05 22:10:50 +0100 (Sat, 05 Jan 2008) | 2 lines
Use markup.
........
r59757 | christian.heimes | 2008-01-05 22:35:52 +0100 (Sat, 05 Jan 2008) | 1 line
Final adjustments for #1601
........
r59758 | guido.van.rossum | 2008-01-05 23:19:06 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
Fix by John Nagle.
........
r59759 | guido.van.rossum | 2008-01-05 23:20:01 +0100 (Sat, 05 Jan 2008) | 2 lines
Add John Nagle (of issue #1637).
........
r59765 | raymond.hettinger | 2008-01-06 10:02:24 +0100 (Sun, 06 Jan 2008) | 1 line
Small code simplification. Forgot that classmethods can be called from intances.
........
r59766 | martin.v.loewis | 2008-01-06 11:09:48 +0100 (Sun, 06 Jan 2008) | 2 lines
Use vcbuild for VS 2009.
........
r59767 | martin.v.loewis | 2008-01-06 12:03:43 +0100 (Sun, 06 Jan 2008) | 2 lines
Package using VS 2008.
........
r59768 | martin.v.loewis | 2008-01-06 12:13:16 +0100 (Sun, 06 Jan 2008) | 2 lines
Don't try to package msvcr90 for the moment.
........
r59769 | georg.brandl | 2008-01-06 15:17:36 +0100 (Sun, 06 Jan 2008) | 4 lines
#1696393: don't check for '.' and '..' in ntpath.walk since
they aren't returned from os.listdir anymore.
Reported by Michael Haggerty.
........
r59770 | georg.brandl | 2008-01-06 15:27:15 +0100 (Sun, 06 Jan 2008) | 3 lines
#1742: don't raise exception on os.path.relpath("a", "a"), but return os.curdir.
Reported by Jesse Towner.
........
r59771 | georg.brandl | 2008-01-06 15:33:52 +0100 (Sun, 06 Jan 2008) | 2 lines
#1591: Clarify docstring of Popen3.
........
r59772 | georg.brandl | 2008-01-06 16:30:34 +0100 (Sun, 06 Jan 2008) | 2 lines
#1680: fix context manager example function name.
........
r59773 | georg.brandl | 2008-01-06 16:34:57 +0100 (Sun, 06 Jan 2008) | 2 lines
#1755097: document default values for [].sort() and sorted().
........
2008-01-06 12:59:19 -04:00
|
|
|
self.assertEqual(p.scheme, "http")
|
|
|
|
self.assertEqual(p.netloc, "User@example.com:Pass@www.python.org:080")
|
|
|
|
self.assertEqual(p.path, "/doc/")
|
|
|
|
self.assertEqual(p.query, "query=yes")
|
|
|
|
self.assertEqual(p.fragment, "frag")
|
|
|
|
self.assertEqual(p.username, "User@example.com")
|
|
|
|
self.assertEqual(p.password, "Pass")
|
|
|
|
self.assertEqual(p.hostname, "www.python.org")
|
|
|
|
self.assertEqual(p.port, 80)
|
|
|
|
self.assertEqual(p.geturl(), url)
|
|
|
|
|
2010-11-30 11:48:08 -04:00
|
|
|
# And check them all again, only with bytes this time
|
|
|
|
url = b"HTTP://WWW.PYTHON.ORG/doc/#frag"
|
|
|
|
p = urllib.parse.urlsplit(url)
|
|
|
|
self.assertEqual(p.scheme, b"http")
|
|
|
|
self.assertEqual(p.netloc, b"WWW.PYTHON.ORG")
|
|
|
|
self.assertEqual(p.path, b"/doc/")
|
|
|
|
self.assertEqual(p.query, b"")
|
|
|
|
self.assertEqual(p.fragment, b"frag")
|
|
|
|
self.assertEqual(p.username, None)
|
|
|
|
self.assertEqual(p.password, None)
|
|
|
|
self.assertEqual(p.hostname, b"www.python.org")
|
|
|
|
self.assertEqual(p.port, None)
|
|
|
|
self.assertEqual(p.geturl()[4:], url[4:])
|
|
|
|
|
|
|
|
url = b"http://User:Pass@www.python.org:080/doc/?query=yes#frag"
|
|
|
|
p = urllib.parse.urlsplit(url)
|
|
|
|
self.assertEqual(p.scheme, b"http")
|
|
|
|
self.assertEqual(p.netloc, b"User:Pass@www.python.org:080")
|
|
|
|
self.assertEqual(p.path, b"/doc/")
|
|
|
|
self.assertEqual(p.query, b"query=yes")
|
|
|
|
self.assertEqual(p.fragment, b"frag")
|
|
|
|
self.assertEqual(p.username, b"User")
|
|
|
|
self.assertEqual(p.password, b"Pass")
|
|
|
|
self.assertEqual(p.hostname, b"www.python.org")
|
|
|
|
self.assertEqual(p.port, 80)
|
|
|
|
self.assertEqual(p.geturl(), url)
|
|
|
|
|
|
|
|
url = b"http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag"
|
|
|
|
p = urllib.parse.urlsplit(url)
|
|
|
|
self.assertEqual(p.scheme, b"http")
|
|
|
|
self.assertEqual(p.netloc, b"User@example.com:Pass@www.python.org:080")
|
|
|
|
self.assertEqual(p.path, b"/doc/")
|
|
|
|
self.assertEqual(p.query, b"query=yes")
|
|
|
|
self.assertEqual(p.fragment, b"frag")
|
|
|
|
self.assertEqual(p.username, b"User@example.com")
|
|
|
|
self.assertEqual(p.password, b"Pass")
|
|
|
|
self.assertEqual(p.hostname, b"www.python.org")
|
|
|
|
self.assertEqual(p.port, 80)
|
|
|
|
self.assertEqual(p.geturl(), url)
|
Merged revisions 59703-59773 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59704 | christian.heimes | 2008-01-04 04:15:05 +0100 (Fri, 04 Jan 2008) | 1 line
Moved include "Python.h" in front of other imports to silence a warning.
........
r59706 | raymond.hettinger | 2008-01-04 04:22:53 +0100 (Fri, 04 Jan 2008) | 10 lines
Minor fix-ups to named tuples:
* Make the _replace() method respect subclassing.
* Using property() to make _fields read-only wasn't a good idea.
It caused len(Point._fields) to fail.
* Add note to _cast() about length checking and alternative with the star-operator.
........
r59707 | jeffrey.yasskin | 2008-01-04 09:01:23 +0100 (Fri, 04 Jan 2008) | 3 lines
Make math.{floor,ceil}({int,long}) return float again for backwards
compatibility after r59671 made them return integral types.
........
r59709 | christian.heimes | 2008-01-04 14:21:07 +0100 (Fri, 04 Jan 2008) | 1 line
Bug #1713: posixpath.ismount() claims symlink to a mountpoint is a mountpoint.
........
r59712 | lars.gustaebel | 2008-01-04 15:00:33 +0100 (Fri, 04 Jan 2008) | 5 lines
Issue #1735: TarFile.extractall() now correctly sets
directory permissions and times.
(will backport to 2.5)
........
r59714 | andrew.kuchling | 2008-01-04 15:47:17 +0100 (Fri, 04 Jan 2008) | 1 line
Update links to bug/patch tracker
........
r59716 | christian.heimes | 2008-01-04 16:23:30 +0100 (Fri, 04 Jan 2008) | 1 line
Added interface to Windows' WSAIoctl and a simple example for a network sniffer.
........
r59717 | christian.heimes | 2008-01-04 16:29:00 +0100 (Fri, 04 Jan 2008) | 1 line
And here is the rest of Hirokazu Yamamoto's patch for VS6.0 support. Thanks Hiro!
........
r59719 | christian.heimes | 2008-01-04 16:34:06 +0100 (Fri, 04 Jan 2008) | 1 line
Reverted last transaction. It's the wrong branch.
........
r59721 | christian.heimes | 2008-01-04 16:48:06 +0100 (Fri, 04 Jan 2008) | 1 line
socket.ioctl is only available on Windows
........
r59722 | andrew.kuchling | 2008-01-04 19:24:41 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59723 | andrew.kuchling | 2008-01-04 19:25:05 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59725 | guido.van.rossum | 2008-01-05 01:59:59 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1725 by Mark Dickinson, fixes incorrect conversion of -1e1000
and adds errors for -0x.
........
r59726 | guido.van.rossum | 2008-01-05 02:21:57 +0100 (Sat, 05 Jan 2008) | 2 lines
Patch #1698 by Senthil: allow '@' in username when parsed by urlparse.py.
........
r59727 | raymond.hettinger | 2008-01-05 02:35:43 +0100 (Sat, 05 Jan 2008) | 1 line
Improve namedtuple's _cast() method with a docstring, new name, and error-checking.
........
r59728 | raymond.hettinger | 2008-01-05 03:17:24 +0100 (Sat, 05 Jan 2008) | 1 line
Add error-checking to namedtuple's _replace() method.
........
r59730 | fred.drake | 2008-01-05 05:38:38 +0100 (Sat, 05 Jan 2008) | 2 lines
clean up a comment
........
r59731 | jeffrey.yasskin | 2008-01-05 09:47:13 +0100 (Sat, 05 Jan 2008) | 11 lines
Continue rolling back pep-3141 changes that changed behavior from 2.5. This
round included:
* Revert round to its 2.6 behavior (half away from 0).
* Because round, floor, and ceil always return float again, it's no
longer necessary to have them delegate to __xxx___, so I've ripped
that out of their implementations and the Real ABC. This also helps
in implementing types that work in both 2.6 and 3.0: you return int
from the __xxx__ methods, and let it get enabled by the version
upgrade.
* Make pow(-1, .5) raise a ValueError again.
........
r59736 | andrew.kuchling | 2008-01-05 16:13:49 +0100 (Sat, 05 Jan 2008) | 1 line
Fix comment typo
........
r59738 | thomas.heller | 2008-01-05 18:15:44 +0100 (Sat, 05 Jan 2008) | 1 line
Add myself.
........
r59739 | georg.brandl | 2008-01-05 18:49:17 +0100 (Sat, 05 Jan 2008) | 2 lines
Fix C++-style comment.
........
r59742 | georg.brandl | 2008-01-05 20:28:16 +0100 (Sat, 05 Jan 2008) | 2 lines
Remove with_statement future imports from 2.6 docs.
........
r59743 | georg.brandl | 2008-01-05 20:29:45 +0100 (Sat, 05 Jan 2008) | 2 lines
Simplify index entries; fix #1712.
........
r59744 | georg.brandl | 2008-01-05 20:44:22 +0100 (Sat, 05 Jan 2008) | 2 lines
Doc patch #1730 from Robin Stocker; minor corrections mostly to os.rst.
........
r59749 | georg.brandl | 2008-01-05 21:29:13 +0100 (Sat, 05 Jan 2008) | 2 lines
Revert socket.rst to unix-eol.
........
r59750 | georg.brandl | 2008-01-05 21:33:46 +0100 (Sat, 05 Jan 2008) | 2 lines
Set native svn:eol-style property for text files.
........
r59752 | georg.brandl | 2008-01-05 21:46:29 +0100 (Sat, 05 Jan 2008) | 2 lines
#1719: capitalization error in "UuidCreate".
........
r59753 | georg.brandl | 2008-01-05 22:02:25 +0100 (Sat, 05 Jan 2008) | 2 lines
Repair markup.
........
r59754 | georg.brandl | 2008-01-05 22:10:50 +0100 (Sat, 05 Jan 2008) | 2 lines
Use markup.
........
r59757 | christian.heimes | 2008-01-05 22:35:52 +0100 (Sat, 05 Jan 2008) | 1 line
Final adjustments for #1601
........
r59758 | guido.van.rossum | 2008-01-05 23:19:06 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
Fix by John Nagle.
........
r59759 | guido.van.rossum | 2008-01-05 23:20:01 +0100 (Sat, 05 Jan 2008) | 2 lines
Add John Nagle (of issue #1637).
........
r59765 | raymond.hettinger | 2008-01-06 10:02:24 +0100 (Sun, 06 Jan 2008) | 1 line
Small code simplification. Forgot that classmethods can be called from intances.
........
r59766 | martin.v.loewis | 2008-01-06 11:09:48 +0100 (Sun, 06 Jan 2008) | 2 lines
Use vcbuild for VS 2009.
........
r59767 | martin.v.loewis | 2008-01-06 12:03:43 +0100 (Sun, 06 Jan 2008) | 2 lines
Package using VS 2008.
........
r59768 | martin.v.loewis | 2008-01-06 12:13:16 +0100 (Sun, 06 Jan 2008) | 2 lines
Don't try to package msvcr90 for the moment.
........
r59769 | georg.brandl | 2008-01-06 15:17:36 +0100 (Sun, 06 Jan 2008) | 4 lines
#1696393: don't check for '.' and '..' in ntpath.walk since
they aren't returned from os.listdir anymore.
Reported by Michael Haggerty.
........
r59770 | georg.brandl | 2008-01-06 15:27:15 +0100 (Sun, 06 Jan 2008) | 3 lines
#1742: don't raise exception on os.path.relpath("a", "a"), but return os.curdir.
Reported by Jesse Towner.
........
r59771 | georg.brandl | 2008-01-06 15:33:52 +0100 (Sun, 06 Jan 2008) | 2 lines
#1591: Clarify docstring of Popen3.
........
r59772 | georg.brandl | 2008-01-06 16:30:34 +0100 (Sun, 06 Jan 2008) | 2 lines
#1680: fix context manager example function name.
........
r59773 | georg.brandl | 2008-01-06 16:34:57 +0100 (Sun, 06 Jan 2008) | 2 lines
#1755097: document default values for [].sort() and sorted().
........
2008-01-06 12:59:19 -04:00
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
def test_attributes_bad_port(self):
|
|
|
|
"""Check handling of non-integer ports."""
|
2008-06-18 17:49:58 -03:00
|
|
|
p = urllib.parse.urlsplit("http://www.example.net:foo")
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(p.netloc, "www.example.net:foo")
|
|
|
|
self.assertRaises(ValueError, lambda: p.port)
|
|
|
|
|
2008-06-18 17:49:58 -03:00
|
|
|
p = urllib.parse.urlparse("http://www.example.net:foo")
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(p.netloc, "www.example.net:foo")
|
|
|
|
self.assertRaises(ValueError, lambda: p.port)
|
|
|
|
|
2010-11-30 11:48:08 -04:00
|
|
|
# Once again, repeat ourselves to test bytes
|
|
|
|
p = urllib.parse.urlsplit(b"http://www.example.net:foo")
|
|
|
|
self.assertEqual(p.netloc, b"www.example.net:foo")
|
|
|
|
self.assertRaises(ValueError, lambda: p.port)
|
|
|
|
|
|
|
|
p = urllib.parse.urlparse(b"http://www.example.net:foo")
|
|
|
|
self.assertEqual(p.netloc, b"www.example.net:foo")
|
|
|
|
self.assertRaises(ValueError, lambda: p.port)
|
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
def test_attributes_without_netloc(self):
|
|
|
|
# This example is straight from RFC 3261. It looks like it
|
|
|
|
# should allow the username, hostname, and port to be filled
|
|
|
|
# in, but doesn't. Since it's a URI and doesn't use the
|
|
|
|
# scheme://netloc syntax, the netloc and related attributes
|
|
|
|
# should be left empty.
|
|
|
|
uri = "sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15"
|
2008-06-18 17:49:58 -03:00
|
|
|
p = urllib.parse.urlsplit(uri)
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(p.netloc, "")
|
|
|
|
self.assertEqual(p.username, None)
|
|
|
|
self.assertEqual(p.password, None)
|
|
|
|
self.assertEqual(p.hostname, None)
|
|
|
|
self.assertEqual(p.port, None)
|
|
|
|
self.assertEqual(p.geturl(), uri)
|
|
|
|
|
2008-06-18 17:49:58 -03:00
|
|
|
p = urllib.parse.urlparse(uri)
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(p.netloc, "")
|
|
|
|
self.assertEqual(p.username, None)
|
|
|
|
self.assertEqual(p.password, None)
|
|
|
|
self.assertEqual(p.hostname, None)
|
|
|
|
self.assertEqual(p.port, None)
|
|
|
|
self.assertEqual(p.geturl(), uri)
|
|
|
|
|
2010-11-30 11:48:08 -04:00
|
|
|
# You guessed it, repeating the test with bytes input
|
|
|
|
uri = b"sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15"
|
|
|
|
p = urllib.parse.urlsplit(uri)
|
|
|
|
self.assertEqual(p.netloc, b"")
|
|
|
|
self.assertEqual(p.username, None)
|
|
|
|
self.assertEqual(p.password, None)
|
|
|
|
self.assertEqual(p.hostname, None)
|
|
|
|
self.assertEqual(p.port, None)
|
|
|
|
self.assertEqual(p.geturl(), uri)
|
|
|
|
|
|
|
|
p = urllib.parse.urlparse(uri)
|
|
|
|
self.assertEqual(p.netloc, b"")
|
|
|
|
self.assertEqual(p.username, None)
|
|
|
|
self.assertEqual(p.password, None)
|
|
|
|
self.assertEqual(p.hostname, None)
|
|
|
|
self.assertEqual(p.port, None)
|
|
|
|
self.assertEqual(p.geturl(), uri)
|
|
|
|
|
Merged revisions 59703-59773 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59704 | christian.heimes | 2008-01-04 04:15:05 +0100 (Fri, 04 Jan 2008) | 1 line
Moved include "Python.h" in front of other imports to silence a warning.
........
r59706 | raymond.hettinger | 2008-01-04 04:22:53 +0100 (Fri, 04 Jan 2008) | 10 lines
Minor fix-ups to named tuples:
* Make the _replace() method respect subclassing.
* Using property() to make _fields read-only wasn't a good idea.
It caused len(Point._fields) to fail.
* Add note to _cast() about length checking and alternative with the star-operator.
........
r59707 | jeffrey.yasskin | 2008-01-04 09:01:23 +0100 (Fri, 04 Jan 2008) | 3 lines
Make math.{floor,ceil}({int,long}) return float again for backwards
compatibility after r59671 made them return integral types.
........
r59709 | christian.heimes | 2008-01-04 14:21:07 +0100 (Fri, 04 Jan 2008) | 1 line
Bug #1713: posixpath.ismount() claims symlink to a mountpoint is a mountpoint.
........
r59712 | lars.gustaebel | 2008-01-04 15:00:33 +0100 (Fri, 04 Jan 2008) | 5 lines
Issue #1735: TarFile.extractall() now correctly sets
directory permissions and times.
(will backport to 2.5)
........
r59714 | andrew.kuchling | 2008-01-04 15:47:17 +0100 (Fri, 04 Jan 2008) | 1 line
Update links to bug/patch tracker
........
r59716 | christian.heimes | 2008-01-04 16:23:30 +0100 (Fri, 04 Jan 2008) | 1 line
Added interface to Windows' WSAIoctl and a simple example for a network sniffer.
........
r59717 | christian.heimes | 2008-01-04 16:29:00 +0100 (Fri, 04 Jan 2008) | 1 line
And here is the rest of Hirokazu Yamamoto's patch for VS6.0 support. Thanks Hiro!
........
r59719 | christian.heimes | 2008-01-04 16:34:06 +0100 (Fri, 04 Jan 2008) | 1 line
Reverted last transaction. It's the wrong branch.
........
r59721 | christian.heimes | 2008-01-04 16:48:06 +0100 (Fri, 04 Jan 2008) | 1 line
socket.ioctl is only available on Windows
........
r59722 | andrew.kuchling | 2008-01-04 19:24:41 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59723 | andrew.kuchling | 2008-01-04 19:25:05 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59725 | guido.van.rossum | 2008-01-05 01:59:59 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1725 by Mark Dickinson, fixes incorrect conversion of -1e1000
and adds errors for -0x.
........
r59726 | guido.van.rossum | 2008-01-05 02:21:57 +0100 (Sat, 05 Jan 2008) | 2 lines
Patch #1698 by Senthil: allow '@' in username when parsed by urlparse.py.
........
r59727 | raymond.hettinger | 2008-01-05 02:35:43 +0100 (Sat, 05 Jan 2008) | 1 line
Improve namedtuple's _cast() method with a docstring, new name, and error-checking.
........
r59728 | raymond.hettinger | 2008-01-05 03:17:24 +0100 (Sat, 05 Jan 2008) | 1 line
Add error-checking to namedtuple's _replace() method.
........
r59730 | fred.drake | 2008-01-05 05:38:38 +0100 (Sat, 05 Jan 2008) | 2 lines
clean up a comment
........
r59731 | jeffrey.yasskin | 2008-01-05 09:47:13 +0100 (Sat, 05 Jan 2008) | 11 lines
Continue rolling back pep-3141 changes that changed behavior from 2.5. This
round included:
* Revert round to its 2.6 behavior (half away from 0).
* Because round, floor, and ceil always return float again, it's no
longer necessary to have them delegate to __xxx___, so I've ripped
that out of their implementations and the Real ABC. This also helps
in implementing types that work in both 2.6 and 3.0: you return int
from the __xxx__ methods, and let it get enabled by the version
upgrade.
* Make pow(-1, .5) raise a ValueError again.
........
r59736 | andrew.kuchling | 2008-01-05 16:13:49 +0100 (Sat, 05 Jan 2008) | 1 line
Fix comment typo
........
r59738 | thomas.heller | 2008-01-05 18:15:44 +0100 (Sat, 05 Jan 2008) | 1 line
Add myself.
........
r59739 | georg.brandl | 2008-01-05 18:49:17 +0100 (Sat, 05 Jan 2008) | 2 lines
Fix C++-style comment.
........
r59742 | georg.brandl | 2008-01-05 20:28:16 +0100 (Sat, 05 Jan 2008) | 2 lines
Remove with_statement future imports from 2.6 docs.
........
r59743 | georg.brandl | 2008-01-05 20:29:45 +0100 (Sat, 05 Jan 2008) | 2 lines
Simplify index entries; fix #1712.
........
r59744 | georg.brandl | 2008-01-05 20:44:22 +0100 (Sat, 05 Jan 2008) | 2 lines
Doc patch #1730 from Robin Stocker; minor corrections mostly to os.rst.
........
r59749 | georg.brandl | 2008-01-05 21:29:13 +0100 (Sat, 05 Jan 2008) | 2 lines
Revert socket.rst to unix-eol.
........
r59750 | georg.brandl | 2008-01-05 21:33:46 +0100 (Sat, 05 Jan 2008) | 2 lines
Set native svn:eol-style property for text files.
........
r59752 | georg.brandl | 2008-01-05 21:46:29 +0100 (Sat, 05 Jan 2008) | 2 lines
#1719: capitalization error in "UuidCreate".
........
r59753 | georg.brandl | 2008-01-05 22:02:25 +0100 (Sat, 05 Jan 2008) | 2 lines
Repair markup.
........
r59754 | georg.brandl | 2008-01-05 22:10:50 +0100 (Sat, 05 Jan 2008) | 2 lines
Use markup.
........
r59757 | christian.heimes | 2008-01-05 22:35:52 +0100 (Sat, 05 Jan 2008) | 1 line
Final adjustments for #1601
........
r59758 | guido.van.rossum | 2008-01-05 23:19:06 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
Fix by John Nagle.
........
r59759 | guido.van.rossum | 2008-01-05 23:20:01 +0100 (Sat, 05 Jan 2008) | 2 lines
Add John Nagle (of issue #1637).
........
r59765 | raymond.hettinger | 2008-01-06 10:02:24 +0100 (Sun, 06 Jan 2008) | 1 line
Small code simplification. Forgot that classmethods can be called from intances.
........
r59766 | martin.v.loewis | 2008-01-06 11:09:48 +0100 (Sun, 06 Jan 2008) | 2 lines
Use vcbuild for VS 2009.
........
r59767 | martin.v.loewis | 2008-01-06 12:03:43 +0100 (Sun, 06 Jan 2008) | 2 lines
Package using VS 2008.
........
r59768 | martin.v.loewis | 2008-01-06 12:13:16 +0100 (Sun, 06 Jan 2008) | 2 lines
Don't try to package msvcr90 for the moment.
........
r59769 | georg.brandl | 2008-01-06 15:17:36 +0100 (Sun, 06 Jan 2008) | 4 lines
#1696393: don't check for '.' and '..' in ntpath.walk since
they aren't returned from os.listdir anymore.
Reported by Michael Haggerty.
........
r59770 | georg.brandl | 2008-01-06 15:27:15 +0100 (Sun, 06 Jan 2008) | 3 lines
#1742: don't raise exception on os.path.relpath("a", "a"), but return os.curdir.
Reported by Jesse Towner.
........
r59771 | georg.brandl | 2008-01-06 15:33:52 +0100 (Sun, 06 Jan 2008) | 2 lines
#1591: Clarify docstring of Popen3.
........
r59772 | georg.brandl | 2008-01-06 16:30:34 +0100 (Sun, 06 Jan 2008) | 2 lines
#1680: fix context manager example function name.
........
r59773 | georg.brandl | 2008-01-06 16:34:57 +0100 (Sun, 06 Jan 2008) | 2 lines
#1755097: document default values for [].sort() and sorted().
........
2008-01-06 12:59:19 -04:00
|
|
|
def test_noslash(self):
|
|
|
|
# Issue 1637: http://foo.com?query is legal
|
2008-06-18 17:49:58 -03:00
|
|
|
self.assertEqual(urllib.parse.urlparse("http://example.com?blahblah=/foo"),
|
Merged revisions 59703-59773 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59704 | christian.heimes | 2008-01-04 04:15:05 +0100 (Fri, 04 Jan 2008) | 1 line
Moved include "Python.h" in front of other imports to silence a warning.
........
r59706 | raymond.hettinger | 2008-01-04 04:22:53 +0100 (Fri, 04 Jan 2008) | 10 lines
Minor fix-ups to named tuples:
* Make the _replace() method respect subclassing.
* Using property() to make _fields read-only wasn't a good idea.
It caused len(Point._fields) to fail.
* Add note to _cast() about length checking and alternative with the star-operator.
........
r59707 | jeffrey.yasskin | 2008-01-04 09:01:23 +0100 (Fri, 04 Jan 2008) | 3 lines
Make math.{floor,ceil}({int,long}) return float again for backwards
compatibility after r59671 made them return integral types.
........
r59709 | christian.heimes | 2008-01-04 14:21:07 +0100 (Fri, 04 Jan 2008) | 1 line
Bug #1713: posixpath.ismount() claims symlink to a mountpoint is a mountpoint.
........
r59712 | lars.gustaebel | 2008-01-04 15:00:33 +0100 (Fri, 04 Jan 2008) | 5 lines
Issue #1735: TarFile.extractall() now correctly sets
directory permissions and times.
(will backport to 2.5)
........
r59714 | andrew.kuchling | 2008-01-04 15:47:17 +0100 (Fri, 04 Jan 2008) | 1 line
Update links to bug/patch tracker
........
r59716 | christian.heimes | 2008-01-04 16:23:30 +0100 (Fri, 04 Jan 2008) | 1 line
Added interface to Windows' WSAIoctl and a simple example for a network sniffer.
........
r59717 | christian.heimes | 2008-01-04 16:29:00 +0100 (Fri, 04 Jan 2008) | 1 line
And here is the rest of Hirokazu Yamamoto's patch for VS6.0 support. Thanks Hiro!
........
r59719 | christian.heimes | 2008-01-04 16:34:06 +0100 (Fri, 04 Jan 2008) | 1 line
Reverted last transaction. It's the wrong branch.
........
r59721 | christian.heimes | 2008-01-04 16:48:06 +0100 (Fri, 04 Jan 2008) | 1 line
socket.ioctl is only available on Windows
........
r59722 | andrew.kuchling | 2008-01-04 19:24:41 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59723 | andrew.kuchling | 2008-01-04 19:25:05 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59725 | guido.van.rossum | 2008-01-05 01:59:59 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1725 by Mark Dickinson, fixes incorrect conversion of -1e1000
and adds errors for -0x.
........
r59726 | guido.van.rossum | 2008-01-05 02:21:57 +0100 (Sat, 05 Jan 2008) | 2 lines
Patch #1698 by Senthil: allow '@' in username when parsed by urlparse.py.
........
r59727 | raymond.hettinger | 2008-01-05 02:35:43 +0100 (Sat, 05 Jan 2008) | 1 line
Improve namedtuple's _cast() method with a docstring, new name, and error-checking.
........
r59728 | raymond.hettinger | 2008-01-05 03:17:24 +0100 (Sat, 05 Jan 2008) | 1 line
Add error-checking to namedtuple's _replace() method.
........
r59730 | fred.drake | 2008-01-05 05:38:38 +0100 (Sat, 05 Jan 2008) | 2 lines
clean up a comment
........
r59731 | jeffrey.yasskin | 2008-01-05 09:47:13 +0100 (Sat, 05 Jan 2008) | 11 lines
Continue rolling back pep-3141 changes that changed behavior from 2.5. This
round included:
* Revert round to its 2.6 behavior (half away from 0).
* Because round, floor, and ceil always return float again, it's no
longer necessary to have them delegate to __xxx___, so I've ripped
that out of their implementations and the Real ABC. This also helps
in implementing types that work in both 2.6 and 3.0: you return int
from the __xxx__ methods, and let it get enabled by the version
upgrade.
* Make pow(-1, .5) raise a ValueError again.
........
r59736 | andrew.kuchling | 2008-01-05 16:13:49 +0100 (Sat, 05 Jan 2008) | 1 line
Fix comment typo
........
r59738 | thomas.heller | 2008-01-05 18:15:44 +0100 (Sat, 05 Jan 2008) | 1 line
Add myself.
........
r59739 | georg.brandl | 2008-01-05 18:49:17 +0100 (Sat, 05 Jan 2008) | 2 lines
Fix C++-style comment.
........
r59742 | georg.brandl | 2008-01-05 20:28:16 +0100 (Sat, 05 Jan 2008) | 2 lines
Remove with_statement future imports from 2.6 docs.
........
r59743 | georg.brandl | 2008-01-05 20:29:45 +0100 (Sat, 05 Jan 2008) | 2 lines
Simplify index entries; fix #1712.
........
r59744 | georg.brandl | 2008-01-05 20:44:22 +0100 (Sat, 05 Jan 2008) | 2 lines
Doc patch #1730 from Robin Stocker; minor corrections mostly to os.rst.
........
r59749 | georg.brandl | 2008-01-05 21:29:13 +0100 (Sat, 05 Jan 2008) | 2 lines
Revert socket.rst to unix-eol.
........
r59750 | georg.brandl | 2008-01-05 21:33:46 +0100 (Sat, 05 Jan 2008) | 2 lines
Set native svn:eol-style property for text files.
........
r59752 | georg.brandl | 2008-01-05 21:46:29 +0100 (Sat, 05 Jan 2008) | 2 lines
#1719: capitalization error in "UuidCreate".
........
r59753 | georg.brandl | 2008-01-05 22:02:25 +0100 (Sat, 05 Jan 2008) | 2 lines
Repair markup.
........
r59754 | georg.brandl | 2008-01-05 22:10:50 +0100 (Sat, 05 Jan 2008) | 2 lines
Use markup.
........
r59757 | christian.heimes | 2008-01-05 22:35:52 +0100 (Sat, 05 Jan 2008) | 1 line
Final adjustments for #1601
........
r59758 | guido.van.rossum | 2008-01-05 23:19:06 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
Fix by John Nagle.
........
r59759 | guido.van.rossum | 2008-01-05 23:20:01 +0100 (Sat, 05 Jan 2008) | 2 lines
Add John Nagle (of issue #1637).
........
r59765 | raymond.hettinger | 2008-01-06 10:02:24 +0100 (Sun, 06 Jan 2008) | 1 line
Small code simplification. Forgot that classmethods can be called from intances.
........
r59766 | martin.v.loewis | 2008-01-06 11:09:48 +0100 (Sun, 06 Jan 2008) | 2 lines
Use vcbuild for VS 2009.
........
r59767 | martin.v.loewis | 2008-01-06 12:03:43 +0100 (Sun, 06 Jan 2008) | 2 lines
Package using VS 2008.
........
r59768 | martin.v.loewis | 2008-01-06 12:13:16 +0100 (Sun, 06 Jan 2008) | 2 lines
Don't try to package msvcr90 for the moment.
........
r59769 | georg.brandl | 2008-01-06 15:17:36 +0100 (Sun, 06 Jan 2008) | 4 lines
#1696393: don't check for '.' and '..' in ntpath.walk since
they aren't returned from os.listdir anymore.
Reported by Michael Haggerty.
........
r59770 | georg.brandl | 2008-01-06 15:27:15 +0100 (Sun, 06 Jan 2008) | 3 lines
#1742: don't raise exception on os.path.relpath("a", "a"), but return os.curdir.
Reported by Jesse Towner.
........
r59771 | georg.brandl | 2008-01-06 15:33:52 +0100 (Sun, 06 Jan 2008) | 2 lines
#1591: Clarify docstring of Popen3.
........
r59772 | georg.brandl | 2008-01-06 16:30:34 +0100 (Sun, 06 Jan 2008) | 2 lines
#1680: fix context manager example function name.
........
r59773 | georg.brandl | 2008-01-06 16:34:57 +0100 (Sun, 06 Jan 2008) | 2 lines
#1755097: document default values for [].sort() and sorted().
........
2008-01-06 12:59:19 -04:00
|
|
|
('http', 'example.com', '', '', 'blahblah=/foo', ''))
|
2010-11-30 11:48:08 -04:00
|
|
|
self.assertEqual(urllib.parse.urlparse(b"http://example.com?blahblah=/foo"),
|
|
|
|
(b'http', b'example.com', b'', b'', b'blahblah=/foo', b''))
|
Merged revisions 59703-59773 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59704 | christian.heimes | 2008-01-04 04:15:05 +0100 (Fri, 04 Jan 2008) | 1 line
Moved include "Python.h" in front of other imports to silence a warning.
........
r59706 | raymond.hettinger | 2008-01-04 04:22:53 +0100 (Fri, 04 Jan 2008) | 10 lines
Minor fix-ups to named tuples:
* Make the _replace() method respect subclassing.
* Using property() to make _fields read-only wasn't a good idea.
It caused len(Point._fields) to fail.
* Add note to _cast() about length checking and alternative with the star-operator.
........
r59707 | jeffrey.yasskin | 2008-01-04 09:01:23 +0100 (Fri, 04 Jan 2008) | 3 lines
Make math.{floor,ceil}({int,long}) return float again for backwards
compatibility after r59671 made them return integral types.
........
r59709 | christian.heimes | 2008-01-04 14:21:07 +0100 (Fri, 04 Jan 2008) | 1 line
Bug #1713: posixpath.ismount() claims symlink to a mountpoint is a mountpoint.
........
r59712 | lars.gustaebel | 2008-01-04 15:00:33 +0100 (Fri, 04 Jan 2008) | 5 lines
Issue #1735: TarFile.extractall() now correctly sets
directory permissions and times.
(will backport to 2.5)
........
r59714 | andrew.kuchling | 2008-01-04 15:47:17 +0100 (Fri, 04 Jan 2008) | 1 line
Update links to bug/patch tracker
........
r59716 | christian.heimes | 2008-01-04 16:23:30 +0100 (Fri, 04 Jan 2008) | 1 line
Added interface to Windows' WSAIoctl and a simple example for a network sniffer.
........
r59717 | christian.heimes | 2008-01-04 16:29:00 +0100 (Fri, 04 Jan 2008) | 1 line
And here is the rest of Hirokazu Yamamoto's patch for VS6.0 support. Thanks Hiro!
........
r59719 | christian.heimes | 2008-01-04 16:34:06 +0100 (Fri, 04 Jan 2008) | 1 line
Reverted last transaction. It's the wrong branch.
........
r59721 | christian.heimes | 2008-01-04 16:48:06 +0100 (Fri, 04 Jan 2008) | 1 line
socket.ioctl is only available on Windows
........
r59722 | andrew.kuchling | 2008-01-04 19:24:41 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59723 | andrew.kuchling | 2008-01-04 19:25:05 +0100 (Fri, 04 Jan 2008) | 1 line
Fix markup
........
r59725 | guido.van.rossum | 2008-01-05 01:59:59 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1725 by Mark Dickinson, fixes incorrect conversion of -1e1000
and adds errors for -0x.
........
r59726 | guido.van.rossum | 2008-01-05 02:21:57 +0100 (Sat, 05 Jan 2008) | 2 lines
Patch #1698 by Senthil: allow '@' in username when parsed by urlparse.py.
........
r59727 | raymond.hettinger | 2008-01-05 02:35:43 +0100 (Sat, 05 Jan 2008) | 1 line
Improve namedtuple's _cast() method with a docstring, new name, and error-checking.
........
r59728 | raymond.hettinger | 2008-01-05 03:17:24 +0100 (Sat, 05 Jan 2008) | 1 line
Add error-checking to namedtuple's _replace() method.
........
r59730 | fred.drake | 2008-01-05 05:38:38 +0100 (Sat, 05 Jan 2008) | 2 lines
clean up a comment
........
r59731 | jeffrey.yasskin | 2008-01-05 09:47:13 +0100 (Sat, 05 Jan 2008) | 11 lines
Continue rolling back pep-3141 changes that changed behavior from 2.5. This
round included:
* Revert round to its 2.6 behavior (half away from 0).
* Because round, floor, and ceil always return float again, it's no
longer necessary to have them delegate to __xxx___, so I've ripped
that out of their implementations and the Real ABC. This also helps
in implementing types that work in both 2.6 and 3.0: you return int
from the __xxx__ methods, and let it get enabled by the version
upgrade.
* Make pow(-1, .5) raise a ValueError again.
........
r59736 | andrew.kuchling | 2008-01-05 16:13:49 +0100 (Sat, 05 Jan 2008) | 1 line
Fix comment typo
........
r59738 | thomas.heller | 2008-01-05 18:15:44 +0100 (Sat, 05 Jan 2008) | 1 line
Add myself.
........
r59739 | georg.brandl | 2008-01-05 18:49:17 +0100 (Sat, 05 Jan 2008) | 2 lines
Fix C++-style comment.
........
r59742 | georg.brandl | 2008-01-05 20:28:16 +0100 (Sat, 05 Jan 2008) | 2 lines
Remove with_statement future imports from 2.6 docs.
........
r59743 | georg.brandl | 2008-01-05 20:29:45 +0100 (Sat, 05 Jan 2008) | 2 lines
Simplify index entries; fix #1712.
........
r59744 | georg.brandl | 2008-01-05 20:44:22 +0100 (Sat, 05 Jan 2008) | 2 lines
Doc patch #1730 from Robin Stocker; minor corrections mostly to os.rst.
........
r59749 | georg.brandl | 2008-01-05 21:29:13 +0100 (Sat, 05 Jan 2008) | 2 lines
Revert socket.rst to unix-eol.
........
r59750 | georg.brandl | 2008-01-05 21:33:46 +0100 (Sat, 05 Jan 2008) | 2 lines
Set native svn:eol-style property for text files.
........
r59752 | georg.brandl | 2008-01-05 21:46:29 +0100 (Sat, 05 Jan 2008) | 2 lines
#1719: capitalization error in "UuidCreate".
........
r59753 | georg.brandl | 2008-01-05 22:02:25 +0100 (Sat, 05 Jan 2008) | 2 lines
Repair markup.
........
r59754 | georg.brandl | 2008-01-05 22:10:50 +0100 (Sat, 05 Jan 2008) | 2 lines
Use markup.
........
r59757 | christian.heimes | 2008-01-05 22:35:52 +0100 (Sat, 05 Jan 2008) | 1 line
Final adjustments for #1601
........
r59758 | guido.van.rossum | 2008-01-05 23:19:06 +0100 (Sat, 05 Jan 2008) | 3 lines
Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
Fix by John Nagle.
........
r59759 | guido.van.rossum | 2008-01-05 23:20:01 +0100 (Sat, 05 Jan 2008) | 2 lines
Add John Nagle (of issue #1637).
........
r59765 | raymond.hettinger | 2008-01-06 10:02:24 +0100 (Sun, 06 Jan 2008) | 1 line
Small code simplification. Forgot that classmethods can be called from intances.
........
r59766 | martin.v.loewis | 2008-01-06 11:09:48 +0100 (Sun, 06 Jan 2008) | 2 lines
Use vcbuild for VS 2009.
........
r59767 | martin.v.loewis | 2008-01-06 12:03:43 +0100 (Sun, 06 Jan 2008) | 2 lines
Package using VS 2008.
........
r59768 | martin.v.loewis | 2008-01-06 12:13:16 +0100 (Sun, 06 Jan 2008) | 2 lines
Don't try to package msvcr90 for the moment.
........
r59769 | georg.brandl | 2008-01-06 15:17:36 +0100 (Sun, 06 Jan 2008) | 4 lines
#1696393: don't check for '.' and '..' in ntpath.walk since
they aren't returned from os.listdir anymore.
Reported by Michael Haggerty.
........
r59770 | georg.brandl | 2008-01-06 15:27:15 +0100 (Sun, 06 Jan 2008) | 3 lines
#1742: don't raise exception on os.path.relpath("a", "a"), but return os.curdir.
Reported by Jesse Towner.
........
r59771 | georg.brandl | 2008-01-06 15:33:52 +0100 (Sun, 06 Jan 2008) | 2 lines
#1591: Clarify docstring of Popen3.
........
r59772 | georg.brandl | 2008-01-06 16:30:34 +0100 (Sun, 06 Jan 2008) | 2 lines
#1680: fix context manager example function name.
........
r59773 | georg.brandl | 2008-01-06 16:34:57 +0100 (Sun, 06 Jan 2008) | 2 lines
#1755097: document default values for [].sort() and sorted().
........
2008-01-06 12:59:19 -04:00
|
|
|
|
2010-08-04 01:50:44 -03:00
|
|
|
def test_withoutscheme(self):
|
|
|
|
# Test urlparse without scheme
|
|
|
|
# Issue 754016: urlparse goes wrong with IP:port without scheme
|
|
|
|
# RFC 1808 specifies that netloc should start with //, urlparse expects
|
|
|
|
# the same, otherwise it classifies the portion of url as path.
|
|
|
|
self.assertEqual(urllib.parse.urlparse("path"),
|
|
|
|
('','','path','','',''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse("//www.python.org:80"),
|
|
|
|
('','www.python.org:80','','','',''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"),
|
|
|
|
('http','www.python.org:80','','','',''))
|
2010-11-30 11:48:08 -04:00
|
|
|
# Repeat for bytes input
|
|
|
|
self.assertEqual(urllib.parse.urlparse(b"path"),
|
|
|
|
(b'',b'',b'path',b'',b'',b''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse(b"//www.python.org:80"),
|
|
|
|
(b'',b'www.python.org:80',b'',b'',b'',b''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"),
|
|
|
|
(b'http',b'www.python.org:80',b'',b'',b'',b''))
|
2010-08-04 01:50:44 -03:00
|
|
|
|
|
|
|
def test_portseparator(self):
|
|
|
|
# Issue 754016 makes changes for port separator ':' from scheme separator
|
|
|
|
self.assertEqual(urllib.parse.urlparse("path:80"),
|
|
|
|
('','','path:80','','',''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse("http:"),('http','','','','',''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse("https:"),('https','','','','',''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"),
|
|
|
|
('http','www.python.org:80','','','',''))
|
2010-11-30 11:48:08 -04:00
|
|
|
# As usual, need to check bytes input as well
|
|
|
|
self.assertEqual(urllib.parse.urlparse(b"path:80"),
|
|
|
|
(b'',b'',b'path:80',b'',b'',b''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse(b"http:"),(b'http',b'',b'',b'',b'',b''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse(b"https:"),(b'https',b'',b'',b'',b'',b''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"),
|
|
|
|
(b'http',b'www.python.org:80',b'',b'',b'',b''))
|
2010-08-04 01:50:44 -03:00
|
|
|
|
2008-07-07 15:24:11 -03:00
|
|
|
def test_usingsys(self):
|
|
|
|
# Issue 3314: sys module is used in the error
|
|
|
|
self.assertRaises(TypeError, urllib.parse.urlencode, "foo")
|
|
|
|
|
2010-02-19 03:42:50 -04:00
|
|
|
def test_anyscheme(self):
|
|
|
|
# Issue 7904: s3://foo.com/stuff has netloc "foo.com".
|
2010-02-19 10:49:02 -04:00
|
|
|
self.assertEqual(urllib.parse.urlparse("s3://foo.com/stuff"),
|
|
|
|
('s3', 'foo.com', '/stuff', '', '', ''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff"),
|
|
|
|
('x-newscheme', 'foo.com', '/stuff', '', '', ''))
|
2010-11-30 11:48:08 -04:00
|
|
|
# And for bytes...
|
|
|
|
self.assertEqual(urllib.parse.urlparse(b"s3://foo.com/stuff"),
|
|
|
|
(b's3', b'foo.com', b'/stuff', b'', b'', b''))
|
|
|
|
self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff"),
|
|
|
|
(b'x-newscheme', b'foo.com', b'/stuff', b'', b'', b''))
|
|
|
|
|
|
|
|
def test_mixed_types_rejected(self):
|
|
|
|
# Several functions that process either strings or ASCII encoded bytes
|
|
|
|
# accept multiple arguments. Check they reject mixed type input
|
2010-11-30 22:32:32 -04:00
|
|
|
with self.assertRaisesRegex(TypeError, "Cannot mix str"):
|
2010-11-30 11:48:08 -04:00
|
|
|
urllib.parse.urlparse("www.python.org", b"http")
|
2010-11-30 22:32:32 -04:00
|
|
|
with self.assertRaisesRegex(TypeError, "Cannot mix str"):
|
2010-11-30 11:48:08 -04:00
|
|
|
urllib.parse.urlparse(b"www.python.org", "http")
|
2010-11-30 22:32:32 -04:00
|
|
|
with self.assertRaisesRegex(TypeError, "Cannot mix str"):
|
2010-11-30 11:48:08 -04:00
|
|
|
urllib.parse.urlsplit("www.python.org", b"http")
|
2010-11-30 22:32:32 -04:00
|
|
|
with self.assertRaisesRegex(TypeError, "Cannot mix str"):
|
2010-11-30 11:48:08 -04:00
|
|
|
urllib.parse.urlsplit(b"www.python.org", "http")
|
2010-11-30 22:32:32 -04:00
|
|
|
with self.assertRaisesRegex(TypeError, "Cannot mix str"):
|
2010-11-30 11:48:08 -04:00
|
|
|
urllib.parse.urlunparse(( b"http", "www.python.org","","","",""))
|
2010-11-30 22:32:32 -04:00
|
|
|
with self.assertRaisesRegex(TypeError, "Cannot mix str"):
|
2010-11-30 11:48:08 -04:00
|
|
|
urllib.parse.urlunparse(("http", b"www.python.org","","","",""))
|
2010-11-30 22:32:32 -04:00
|
|
|
with self.assertRaisesRegex(TypeError, "Cannot mix str"):
|
2010-11-30 11:48:08 -04:00
|
|
|
urllib.parse.urlunsplit((b"http", "www.python.org","","",""))
|
2010-11-30 22:32:32 -04:00
|
|
|
with self.assertRaisesRegex(TypeError, "Cannot mix str"):
|
2010-11-30 11:48:08 -04:00
|
|
|
urllib.parse.urlunsplit(("http", b"www.python.org","","",""))
|
2010-11-30 22:32:32 -04:00
|
|
|
with self.assertRaisesRegex(TypeError, "Cannot mix str"):
|
2010-11-30 11:48:08 -04:00
|
|
|
urllib.parse.urljoin("http://python.org", b"http://python.org")
|
2010-11-30 22:32:32 -04:00
|
|
|
with self.assertRaisesRegex(TypeError, "Cannot mix str"):
|
2010-11-30 11:48:08 -04:00
|
|
|
urllib.parse.urljoin(b"http://python.org", "http://python.org")
|
|
|
|
|
|
|
|
def _check_result_type(self, str_type):
|
|
|
|
num_args = len(str_type._fields)
|
|
|
|
bytes_type = str_type._encoded_counterpart
|
|
|
|
self.assertIs(bytes_type._decoded_counterpart, str_type)
|
|
|
|
str_args = ('',) * num_args
|
|
|
|
bytes_args = (b'',) * num_args
|
|
|
|
str_result = str_type(*str_args)
|
|
|
|
bytes_result = bytes_type(*bytes_args)
|
|
|
|
encoding = 'ascii'
|
|
|
|
errors = 'strict'
|
|
|
|
self.assertEqual(str_result, str_args)
|
|
|
|
self.assertEqual(bytes_result.decode(), str_args)
|
|
|
|
self.assertEqual(bytes_result.decode(), str_result)
|
|
|
|
self.assertEqual(bytes_result.decode(encoding), str_args)
|
|
|
|
self.assertEqual(bytes_result.decode(encoding), str_result)
|
|
|
|
self.assertEqual(bytes_result.decode(encoding, errors), str_args)
|
|
|
|
self.assertEqual(bytes_result.decode(encoding, errors), str_result)
|
|
|
|
self.assertEqual(bytes_result, bytes_args)
|
|
|
|
self.assertEqual(str_result.encode(), bytes_args)
|
|
|
|
self.assertEqual(str_result.encode(), bytes_result)
|
|
|
|
self.assertEqual(str_result.encode(encoding), bytes_args)
|
|
|
|
self.assertEqual(str_result.encode(encoding), bytes_result)
|
|
|
|
self.assertEqual(str_result.encode(encoding, errors), bytes_args)
|
|
|
|
self.assertEqual(str_result.encode(encoding, errors), bytes_result)
|
|
|
|
|
|
|
|
def test_result_pairs(self):
|
|
|
|
# Check encoding and decoding between result pairs
|
|
|
|
result_types = [
|
|
|
|
urllib.parse.DefragResult,
|
|
|
|
urllib.parse.SplitResult,
|
|
|
|
urllib.parse.ParseResult,
|
|
|
|
]
|
|
|
|
for result_type in result_types:
|
|
|
|
self._check_result_type(result_type)
|
|
|
|
|
2011-01-14 09:05:19 -04:00
|
|
|
def test_parse_qs_encoding(self):
|
|
|
|
result = urllib.parse.parse_qs("key=\u0141%E9", encoding="latin-1")
|
|
|
|
self.assertEqual(result, {'key': ['\u0141\xE9']})
|
|
|
|
result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="utf-8")
|
|
|
|
self.assertEqual(result, {'key': ['\u0141\xE9']})
|
|
|
|
result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="ascii")
|
|
|
|
self.assertEqual(result, {'key': ['\u0141\ufffd\ufffd']})
|
|
|
|
result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii")
|
|
|
|
self.assertEqual(result, {'key': ['\u0141\ufffd-']})
|
|
|
|
result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii",
|
|
|
|
errors="ignore")
|
|
|
|
self.assertEqual(result, {'key': ['\u0141-']})
|
|
|
|
|
|
|
|
def test_parse_qsl_encoding(self):
|
|
|
|
result = urllib.parse.parse_qsl("key=\u0141%E9", encoding="latin-1")
|
|
|
|
self.assertEqual(result, [('key', '\u0141\xE9')])
|
|
|
|
result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="utf-8")
|
|
|
|
self.assertEqual(result, [('key', '\u0141\xE9')])
|
|
|
|
result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="ascii")
|
|
|
|
self.assertEqual(result, [('key', '\u0141\ufffd\ufffd')])
|
|
|
|
result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii")
|
|
|
|
self.assertEqual(result, [('key', '\u0141\ufffd-')])
|
|
|
|
result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii",
|
|
|
|
errors="ignore")
|
|
|
|
self.assertEqual(result, [('key', '\u0141-')])
|
|
|
|
|
2011-07-23 07:27:45 -03:00
|
|
|
def test_splitnport(self):
|
|
|
|
# Normal cases are exercised by other tests; ensure that we also
|
|
|
|
# catch cases with no port specified. (testcase ensuring coverage)
|
|
|
|
result = urllib.parse.splitnport('parrot:88')
|
|
|
|
self.assertEqual(result, ('parrot', 88))
|
|
|
|
result = urllib.parse.splitnport('parrot')
|
|
|
|
self.assertEqual(result, ('parrot', -1))
|
|
|
|
result = urllib.parse.splitnport('parrot', 55)
|
|
|
|
self.assertEqual(result, ('parrot', 55))
|
|
|
|
result = urllib.parse.splitnport('parrot:')
|
|
|
|
self.assertEqual(result, ('parrot', None))
|
|
|
|
|
|
|
|
def test_splitquery(self):
|
|
|
|
# Normal cases are exercised by other tests; ensure that we also
|
|
|
|
# catch cases with no port specified (testcase ensuring coverage)
|
|
|
|
result = urllib.parse.splitquery('http://python.org/fake?foo=bar')
|
|
|
|
self.assertEqual(result, ('http://python.org/fake', 'foo=bar'))
|
|
|
|
result = urllib.parse.splitquery('http://python.org/fake?foo=bar?')
|
|
|
|
self.assertEqual(result, ('http://python.org/fake?foo=bar', ''))
|
|
|
|
result = urllib.parse.splitquery('http://python.org/fake')
|
|
|
|
self.assertEqual(result, ('http://python.org/fake', None))
|
|
|
|
|
|
|
|
def test_splitvalue(self):
|
|
|
|
# Normal cases are exercised by other tests; test pathological cases
|
|
|
|
# with no key/value pairs. (testcase ensuring coverage)
|
|
|
|
result = urllib.parse.splitvalue('foo=bar')
|
|
|
|
self.assertEqual(result, ('foo', 'bar'))
|
|
|
|
result = urllib.parse.splitvalue('foo=')
|
|
|
|
self.assertEqual(result, ('foo', ''))
|
|
|
|
result = urllib.parse.splitvalue('foobar')
|
|
|
|
self.assertEqual(result, ('foobar', None))
|
|
|
|
|
|
|
|
def test_to_bytes(self):
|
|
|
|
result = urllib.parse.to_bytes('http://www.python.org')
|
|
|
|
self.assertEqual(result, 'http://www.python.org')
|
|
|
|
self.assertRaises(UnicodeError, urllib.parse.to_bytes,
|
|
|
|
'http://www.python.org/medi\u00e6val')
|
|
|
|
|
|
|
|
def test_urlencode_sequences(self):
|
|
|
|
# Other tests incidentally urlencode things; test non-covered cases:
|
|
|
|
# Sequence and object values.
|
|
|
|
result = urllib.parse.urlencode({'a': [1, 2], 'b': (3, 4, 5)}, True)
|
|
|
|
self.assertEqual(result, 'a=1&a=2&b=3&b=4&b=5')
|
|
|
|
|
|
|
|
class Trivial:
|
|
|
|
def __str__(self):
|
|
|
|
return 'trivial'
|
|
|
|
|
|
|
|
result = urllib.parse.urlencode({'a': Trivial()}, True)
|
|
|
|
self.assertEqual(result, 'a=trivial')
|
|
|
|
|
|
|
|
def test_quote_from_bytes(self):
|
|
|
|
self.assertRaises(TypeError, urllib.parse.quote_from_bytes, 'foo')
|
|
|
|
result = urllib.parse.quote_from_bytes(b'archaeological arcana')
|
|
|
|
self.assertEqual(result, 'archaeological%20arcana')
|
|
|
|
result = urllib.parse.quote_from_bytes(b'')
|
|
|
|
self.assertEqual(result, '')
|
|
|
|
|
|
|
|
def test_unquote_to_bytes(self):
|
|
|
|
result = urllib.parse.unquote_to_bytes('abc%20def')
|
|
|
|
self.assertEqual(result, b'abc def')
|
|
|
|
result = urllib.parse.unquote_to_bytes('')
|
|
|
|
self.assertEqual(result, b'')
|
|
|
|
|
|
|
|
def test_quote_errors(self):
|
|
|
|
self.assertRaises(TypeError, urllib.parse.quote, b'foo',
|
|
|
|
encoding='utf-8')
|
|
|
|
self.assertRaises(TypeError, urllib.parse.quote, b'foo', errors='strict')
|
2011-01-14 09:05:19 -04:00
|
|
|
|
2010-02-19 03:42:50 -04:00
|
|
|
|
2002-03-23 01:32:10 -04:00
|
|
|
def test_main():
|
2008-05-20 18:35:26 -03:00
|
|
|
support.run_unittest(UrlParseTestCase)
|
2001-01-05 01:57:04 -04:00
|
|
|
|
2002-03-23 01:32:10 -04:00
|
|
|
if __name__ == "__main__":
|
|
|
|
test_main()
|