Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions
test.test_urlparse.UrlParseTestCase Class Reference

List of all members.

Public Member Functions

def checkRoundtrips
def test_qsl
def test_roundtrips
def test_http_roundtrips
def checkJoin
def test_unparse_parse
def test_RFC1808
def test_RFC2368
def test_RFC2396
def test_RFC3986
def test_urljoins
def test_RFC2732
def test_urldefrag
def test_urlsplit_attributes
def test_attributes_bad_port
def test_attributes_without_netloc
def test_noslash
def test_withoutscheme
def test_portseparator
def test_usingsys
def test_anyscheme
def test_mixed_types_rejected
def test_result_pairs
def test_parse_qs_encoding
def test_parse_qsl_encoding
def test_splitnport
def test_splitquery
def test_splitvalue
def test_to_bytes
def test_urlencode_sequences
def test_quote_from_bytes
def test_unquote_to_bytes
def test_quote_errors

Private Member Functions

def _check_result_type

Detailed Description

Definition at line 40 of file test_urlparse.py.


Member Function Documentation

def test.test_urlparse.UrlParseTestCase._check_result_type (   self,
  str_type 
) [private]

Definition at line 669 of file test_urlparse.py.

00669 
00670     def _check_result_type(self, str_type):
00671         num_args = len(str_type._fields)
00672         bytes_type = str_type._encoded_counterpart
00673         self.assertIs(bytes_type._decoded_counterpart, str_type)
00674         str_args = ('',) * num_args
00675         bytes_args = (b'',) * num_args
00676         str_result = str_type(*str_args)
00677         bytes_result = bytes_type(*bytes_args)
00678         encoding = 'ascii'
00679         errors = 'strict'
00680         self.assertEqual(str_result, str_args)
00681         self.assertEqual(bytes_result.decode(), str_args)
00682         self.assertEqual(bytes_result.decode(), str_result)
00683         self.assertEqual(bytes_result.decode(encoding), str_args)
00684         self.assertEqual(bytes_result.decode(encoding), str_result)
00685         self.assertEqual(bytes_result.decode(encoding, errors), str_args)
00686         self.assertEqual(bytes_result.decode(encoding, errors), str_result)
00687         self.assertEqual(bytes_result, bytes_args)
00688         self.assertEqual(str_result.encode(), bytes_args)
00689         self.assertEqual(str_result.encode(), bytes_result)
00690         self.assertEqual(str_result.encode(encoding), bytes_args)
00691         self.assertEqual(str_result.encode(encoding), bytes_result)
00692         self.assertEqual(str_result.encode(encoding, errors), bytes_args)
00693         self.assertEqual(str_result.encode(encoding, errors), bytes_result)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_urlparse.UrlParseTestCase.checkJoin (   self,
  base,
  relurl,
  expected 
)

Definition at line 175 of file test_urlparse.py.

00175 
00176     def checkJoin(self, base, relurl, expected):
00177         str_components = (base, relurl, expected)
00178         self.assertEqual(urllib.parse.urljoin(base, relurl), expected)
00179         bytes_components = baseb, relurlb, expectedb = [
00180                             x.encode('ascii') for x in str_components]
00181         self.assertEqual(urllib.parse.urljoin(baseb, relurlb), expectedb)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_urlparse.UrlParseTestCase.checkRoundtrips (   self,
  url,
  parsed,
  split 
)

Definition at line 42 of file test_urlparse.py.

00042 
00043     def checkRoundtrips(self, url, parsed, split):
00044         result = urllib.parse.urlparse(url)
00045         self.assertEqual(result, parsed)
00046         t = (result.scheme, result.netloc, result.path,
00047              result.params, result.query, result.fragment)
00048         self.assertEqual(t, parsed)
00049         # put it back together and it should be the same
00050         result2 = urllib.parse.urlunparse(result)
00051         self.assertEqual(result2, url)
00052         self.assertEqual(result2, result.geturl())
00053 
00054         # the result of geturl() is a fixpoint; we can always parse it
00055         # again to get the same result:
00056         result3 = urllib.parse.urlparse(result.geturl())
00057         self.assertEqual(result3.geturl(), result.geturl())
00058         self.assertEqual(result3,          result)
00059         self.assertEqual(result3.scheme,   result.scheme)
00060         self.assertEqual(result3.netloc,   result.netloc)
00061         self.assertEqual(result3.path,     result.path)
00062         self.assertEqual(result3.params,   result.params)
00063         self.assertEqual(result3.query,    result.query)
00064         self.assertEqual(result3.fragment, result.fragment)
00065         self.assertEqual(result3.username, result.username)
00066         self.assertEqual(result3.password, result.password)
00067         self.assertEqual(result3.hostname, result.hostname)
00068         self.assertEqual(result3.port,     result.port)
00069 
00070         # check the roundtrip using urlsplit() as well
00071         result = urllib.parse.urlsplit(url)
00072         self.assertEqual(result, split)
00073         t = (result.scheme, result.netloc, result.path,
00074              result.query, result.fragment)
00075         self.assertEqual(t, split)
00076         result2 = urllib.parse.urlunsplit(result)
00077         self.assertEqual(result2, url)
00078         self.assertEqual(result2, result.geturl())
00079 
00080         # check the fixpoint property of re-parsing the result of geturl()
00081         result3 = urllib.parse.urlsplit(result.geturl())
00082         self.assertEqual(result3.geturl(), result.geturl())
00083         self.assertEqual(result3,          result)
00084         self.assertEqual(result3.scheme,   result.scheme)
00085         self.assertEqual(result3.netloc,   result.netloc)
00086         self.assertEqual(result3.path,     result.path)
00087         self.assertEqual(result3.query,    result.query)
00088         self.assertEqual(result3.fragment, result.fragment)
00089         self.assertEqual(result3.username, result.username)
00090         self.assertEqual(result3.password, result.password)
00091         self.assertEqual(result3.hostname, result.hostname)
00092         self.assertEqual(result3.port,     result.port)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 633 of file test_urlparse.py.

00633 
00634     def test_anyscheme(self):
00635         # Issue 7904: s3://foo.com/stuff has netloc "foo.com".
00636         self.assertEqual(urllib.parse.urlparse("s3://foo.com/stuff"),
00637                          ('s3', 'foo.com', '/stuff', '', '', ''))
00638         self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff"),
00639                          ('x-newscheme', 'foo.com', '/stuff', '', '', ''))
00640         # And for bytes...
00641         self.assertEqual(urllib.parse.urlparse(b"s3://foo.com/stuff"),
00642                          (b's3', b'foo.com', b'/stuff', b'', b'', b''))
00643         self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff"),
00644                          (b'x-newscheme', b'foo.com', b'/stuff', b'', b'', b''))

Here is the call graph for this function:

Check handling of non-integer ports.

Definition at line 527 of file test_urlparse.py.

00527 
00528     def test_attributes_bad_port(self):
00529         """Check handling of non-integer ports."""
00530         p = urllib.parse.urlsplit("http://www.example.net:foo")
00531         self.assertEqual(p.netloc, "www.example.net:foo")
00532         self.assertRaises(ValueError, lambda: p.port)
00533 
00534         p = urllib.parse.urlparse("http://www.example.net:foo")
00535         self.assertEqual(p.netloc, "www.example.net:foo")
00536         self.assertRaises(ValueError, lambda: p.port)
00537 
00538         # Once again, repeat ourselves to test bytes
00539         p = urllib.parse.urlsplit(b"http://www.example.net:foo")
00540         self.assertEqual(p.netloc, b"www.example.net:foo")
00541         self.assertRaises(ValueError, lambda: p.port)
00542 
00543         p = urllib.parse.urlparse(b"http://www.example.net:foo")
00544         self.assertEqual(p.netloc, b"www.example.net:foo")
00545         self.assertRaises(ValueError, lambda: p.port)

Here is the call graph for this function:

Definition at line 546 of file test_urlparse.py.

00546 
00547     def test_attributes_without_netloc(self):
00548         # This example is straight from RFC 3261.  It looks like it
00549         # should allow the username, hostname, and port to be filled
00550         # in, but doesn't.  Since it's a URI and doesn't use the
00551         # scheme://netloc syntax, the netloc and related attributes
00552         # should be left empty.
00553         uri = "sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15"
00554         p = urllib.parse.urlsplit(uri)
00555         self.assertEqual(p.netloc, "")
00556         self.assertEqual(p.username, None)
00557         self.assertEqual(p.password, None)
00558         self.assertEqual(p.hostname, None)
00559         self.assertEqual(p.port, None)
00560         self.assertEqual(p.geturl(), uri)
00561 
00562         p = urllib.parse.urlparse(uri)
00563         self.assertEqual(p.netloc, "")
00564         self.assertEqual(p.username, None)
00565         self.assertEqual(p.password, None)
00566         self.assertEqual(p.hostname, None)
00567         self.assertEqual(p.port, None)
00568         self.assertEqual(p.geturl(), uri)
00569 
00570         # You guessed it, repeating the test with bytes input
00571         uri = b"sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15"
00572         p = urllib.parse.urlsplit(uri)
00573         self.assertEqual(p.netloc, b"")
00574         self.assertEqual(p.username, None)
00575         self.assertEqual(p.password, None)
00576         self.assertEqual(p.hostname, None)
00577         self.assertEqual(p.port, None)
00578         self.assertEqual(p.geturl(), uri)
00579 
00580         p = urllib.parse.urlparse(uri)
00581         self.assertEqual(p.netloc, b"")
00582         self.assertEqual(p.username, None)
00583         self.assertEqual(p.password, None)
00584         self.assertEqual(p.hostname, None)
00585         self.assertEqual(p.port, None)
00586         self.assertEqual(p.geturl(), uri)

Here is the call graph for this function:

Definition at line 137 of file test_urlparse.py.

00137 
00138     def test_http_roundtrips(self):
00139         # urllib.parse.urlsplit treats 'http:' as an optimized special case,
00140         # so we test both 'http:' and 'https:' in all the following.
00141         # Three cheers for white box knowledge!
00142         str_cases = [
00143             ('://www.python.org',
00144              ('www.python.org', '', '', '', ''),
00145              ('www.python.org', '', '', '')),
00146             ('://www.python.org#abc',
00147              ('www.python.org', '', '', '', 'abc'),
00148              ('www.python.org', '', '', 'abc')),
00149             ('://www.python.org?q=abc',
00150              ('www.python.org', '', '', 'q=abc', ''),
00151              ('www.python.org', '', 'q=abc', '')),
00152             ('://www.python.org/#abc',
00153              ('www.python.org', '/', '', '', 'abc'),
00154              ('www.python.org', '/', '', 'abc')),
00155             ('://a/b/c/d;p?q#f',
00156              ('a', '/b/c/d', 'p', 'q', 'f'),
00157              ('a', '/b/c/d;p', 'q', 'f')),
00158             ]
00159         def _encode(t):
00160             return (t[0].encode('ascii'),
00161                     tuple(x.encode('ascii') for x in t[1]),
00162                     tuple(x.encode('ascii') for x in t[2]))
00163         bytes_cases = [_encode(x) for x in str_cases]
00164         str_schemes = ('http', 'https')
00165         bytes_schemes = (b'http', b'https')
00166         str_tests = str_schemes, str_cases
00167         bytes_tests = bytes_schemes, bytes_cases
00168         for schemes, test_cases in (str_tests, bytes_tests):
00169             for scheme in schemes:
00170                 for url, parsed, split in test_cases:
00171                     url = scheme + url
00172                     parsed = (scheme,) + parsed
00173                     split = (scheme,) + split
00174                     self.checkRoundtrips(url, parsed, split)

Here is the call graph for this function:

Definition at line 645 of file test_urlparse.py.

00645 
00646     def test_mixed_types_rejected(self):
00647         # Several functions that process either strings or ASCII encoded bytes
00648         # accept multiple arguments. Check they reject mixed type input
00649         with self.assertRaisesRegex(TypeError, "Cannot mix str"):
00650             urllib.parse.urlparse("www.python.org", b"http")
00651         with self.assertRaisesRegex(TypeError, "Cannot mix str"):
00652             urllib.parse.urlparse(b"www.python.org", "http")
00653         with self.assertRaisesRegex(TypeError, "Cannot mix str"):
00654             urllib.parse.urlsplit("www.python.org", b"http")
00655         with self.assertRaisesRegex(TypeError, "Cannot mix str"):
00656             urllib.parse.urlsplit(b"www.python.org", "http")
00657         with self.assertRaisesRegex(TypeError, "Cannot mix str"):
00658             urllib.parse.urlunparse(( b"http", "www.python.org","","","",""))
00659         with self.assertRaisesRegex(TypeError, "Cannot mix str"):
00660             urllib.parse.urlunparse(("http", b"www.python.org","","","",""))
00661         with self.assertRaisesRegex(TypeError, "Cannot mix str"):
00662             urllib.parse.urlunsplit((b"http", "www.python.org","","",""))
00663         with self.assertRaisesRegex(TypeError, "Cannot mix str"):
00664             urllib.parse.urlunsplit(("http", b"www.python.org","","",""))
00665         with self.assertRaisesRegex(TypeError, "Cannot mix str"):
00666             urllib.parse.urljoin("http://python.org", b"http://python.org")
00667         with self.assertRaisesRegex(TypeError, "Cannot mix str"):
00668             urllib.parse.urljoin(b"http://python.org", "http://python.org")

Here is the call graph for this function:

Definition at line 587 of file test_urlparse.py.

00587 
00588     def test_noslash(self):
00589         # Issue 1637: http://foo.com?query is legal
00590         self.assertEqual(urllib.parse.urlparse("http://example.com?blahblah=/foo"),
00591                          ('http', 'example.com', '', '', 'blahblah=/foo', ''))
00592         self.assertEqual(urllib.parse.urlparse(b"http://example.com?blahblah=/foo"),
00593                          (b'http', b'example.com', b'', b'', b'blahblah=/foo', b''))

Here is the call graph for this function:

Definition at line 704 of file test_urlparse.py.

00704 
00705     def test_parse_qs_encoding(self):
00706         result = urllib.parse.parse_qs("key=\u0141%E9", encoding="latin-1")
00707         self.assertEqual(result, {'key': ['\u0141\xE9']})
00708         result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="utf-8")
00709         self.assertEqual(result, {'key': ['\u0141\xE9']})
00710         result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="ascii")
00711         self.assertEqual(result, {'key': ['\u0141\ufffd\ufffd']})
00712         result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii")
00713         self.assertEqual(result, {'key': ['\u0141\ufffd-']})
00714         result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii",
00715                                                           errors="ignore")
00716         self.assertEqual(result, {'key': ['\u0141-']})

Here is the call graph for this function:

Definition at line 717 of file test_urlparse.py.

00717 
00718     def test_parse_qsl_encoding(self):
00719         result = urllib.parse.parse_qsl("key=\u0141%E9", encoding="latin-1")
00720         self.assertEqual(result, [('key', '\u0141\xE9')])
00721         result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="utf-8")
00722         self.assertEqual(result, [('key', '\u0141\xE9')])
00723         result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="ascii")
00724         self.assertEqual(result, [('key', '\u0141\ufffd\ufffd')])
00725         result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii")
00726         self.assertEqual(result, [('key', '\u0141\ufffd-')])
00727         result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii",
00728                                                           errors="ignore")
00729         self.assertEqual(result, [('key', '\u0141-')])

Here is the call graph for this function:

Definition at line 613 of file test_urlparse.py.

00613 
00614     def test_portseparator(self):
00615         # Issue 754016 makes changes for port separator ':' from scheme separator
00616         self.assertEqual(urllib.parse.urlparse("path:80"),
00617                 ('','','path:80','','',''))
00618         self.assertEqual(urllib.parse.urlparse("http:"),('http','','','','',''))
00619         self.assertEqual(urllib.parse.urlparse("https:"),('https','','','','',''))
00620         self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"),
00621                 ('http','www.python.org:80','','','',''))
00622         # As usual, need to check bytes input as well
00623         self.assertEqual(urllib.parse.urlparse(b"path:80"),
00624                 (b'',b'',b'path:80',b'',b'',b''))
00625         self.assertEqual(urllib.parse.urlparse(b"http:"),(b'http',b'',b'',b'',b'',b''))
00626         self.assertEqual(urllib.parse.urlparse(b"https:"),(b'https',b'',b'',b'',b'',b''))
00627         self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"),
00628                 (b'http',b'www.python.org:80',b'',b'',b'',b''))

Here is the call graph for this function:

Definition at line 93 of file test_urlparse.py.

00093 
00094     def test_qsl(self):
00095         for orig, expect in parse_qsl_test_cases:
00096             result = urllib.parse.parse_qsl(orig, keep_blank_values=True)
00097             self.assertEqual(result, expect, "Error parsing %r" % orig)
00098             expect_without_blanks = [v for v in expect if len(v[1])]
00099             result = urllib.parse.parse_qsl(orig, keep_blank_values=False)
00100             self.assertEqual(result, expect_without_blanks,
00101                             "Error parsing %r" % orig)

Here is the call graph for this function:

Definition at line 794 of file test_urlparse.py.

00794 
00795     def test_quote_errors(self):
00796         self.assertRaises(TypeError, urllib.parse.quote, b'foo',
00797                           encoding='utf-8')
00798         self.assertRaises(TypeError, urllib.parse.quote, b'foo', errors='strict')
00799 

Here is the call graph for this function:

Definition at line 781 of file test_urlparse.py.

00781 
00782     def test_quote_from_bytes(self):
00783         self.assertRaises(TypeError, urllib.parse.quote_from_bytes, 'foo')
00784         result = urllib.parse.quote_from_bytes(b'archaeological arcana')
00785         self.assertEqual(result, 'archaeological%20arcana')
00786         result = urllib.parse.quote_from_bytes(b'')
00787         self.assertEqual(result, '')

Here is the call graph for this function:

Definition at line 694 of file test_urlparse.py.

00694 
00695     def test_result_pairs(self):
00696         # Check encoding and decoding between result pairs
00697         result_types = [
00698           urllib.parse.DefragResult,
00699           urllib.parse.SplitResult,
00700           urllib.parse.ParseResult,
00701         ]
00702         for result_type in result_types:
00703             self._check_result_type(result_type)

Here is the call graph for this function:

Definition at line 189 of file test_urlparse.py.

00189 
00190     def test_RFC1808(self):
00191         # "normal" cases from RFC 1808:
00192         self.checkJoin(RFC1808_BASE, 'g:h', 'g:h')
00193         self.checkJoin(RFC1808_BASE, 'g', 'http://a/b/c/g')
00194         self.checkJoin(RFC1808_BASE, './g', 'http://a/b/c/g')
00195         self.checkJoin(RFC1808_BASE, 'g/', 'http://a/b/c/g/')
00196         self.checkJoin(RFC1808_BASE, '/g', 'http://a/g')
00197         self.checkJoin(RFC1808_BASE, '//g', 'http://g')
00198         self.checkJoin(RFC1808_BASE, 'g?y', 'http://a/b/c/g?y')
00199         self.checkJoin(RFC1808_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x')
00200         self.checkJoin(RFC1808_BASE, '#s', 'http://a/b/c/d;p?q#s')
00201         self.checkJoin(RFC1808_BASE, 'g#s', 'http://a/b/c/g#s')
00202         self.checkJoin(RFC1808_BASE, 'g#s/./x', 'http://a/b/c/g#s/./x')
00203         self.checkJoin(RFC1808_BASE, 'g?y#s', 'http://a/b/c/g?y#s')
00204         self.checkJoin(RFC1808_BASE, 'g;x', 'http://a/b/c/g;x')
00205         self.checkJoin(RFC1808_BASE, 'g;x?y#s', 'http://a/b/c/g;x?y#s')
00206         self.checkJoin(RFC1808_BASE, '.', 'http://a/b/c/')
00207         self.checkJoin(RFC1808_BASE, './', 'http://a/b/c/')
00208         self.checkJoin(RFC1808_BASE, '..', 'http://a/b/')
00209         self.checkJoin(RFC1808_BASE, '../', 'http://a/b/')
00210         self.checkJoin(RFC1808_BASE, '../g', 'http://a/b/g')
00211         self.checkJoin(RFC1808_BASE, '../..', 'http://a/')
00212         self.checkJoin(RFC1808_BASE, '../../', 'http://a/')
00213         self.checkJoin(RFC1808_BASE, '../../g', 'http://a/g')
00214 
00215         # "abnormal" cases from RFC 1808:
00216         self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q#f')
00217         self.checkJoin(RFC1808_BASE, '../../../g', 'http://a/../g')
00218         self.checkJoin(RFC1808_BASE, '../../../../g', 'http://a/../../g')
00219         self.checkJoin(RFC1808_BASE, '/./g', 'http://a/./g')
00220         self.checkJoin(RFC1808_BASE, '/../g', 'http://a/../g')
00221         self.checkJoin(RFC1808_BASE, 'g.', 'http://a/b/c/g.')
00222         self.checkJoin(RFC1808_BASE, '.g', 'http://a/b/c/.g')
00223         self.checkJoin(RFC1808_BASE, 'g..', 'http://a/b/c/g..')
00224         self.checkJoin(RFC1808_BASE, '..g', 'http://a/b/c/..g')
00225         self.checkJoin(RFC1808_BASE, './../g', 'http://a/b/g')
00226         self.checkJoin(RFC1808_BASE, './g/.', 'http://a/b/c/g/')
00227         self.checkJoin(RFC1808_BASE, 'g/./h', 'http://a/b/c/g/h')
00228         self.checkJoin(RFC1808_BASE, 'g/../h', 'http://a/b/c/h')
00229 
00230         # RFC 1808 and RFC 1630 disagree on these (according to RFC 1808),
00231         # so we'll not actually run these tests (which expect 1808 behavior).
00232         #self.checkJoin(RFC1808_BASE, 'http:g', 'http:g')
00233         #self.checkJoin(RFC1808_BASE, 'http:', 'http:')

Here is the call graph for this function:

Definition at line 234 of file test_urlparse.py.

00234 
00235     def test_RFC2368(self):
00236         # Issue 11467: path that starts with a number is not parsed correctly
00237         self.assertEqual(urllib.parse.urlparse('mailto:1337@example.org'),
00238                 ('mailto', '', '1337@example.org', '', '', ''))

Here is the call graph for this function:

Definition at line 239 of file test_urlparse.py.

00239 
00240     def test_RFC2396(self):
00241         # cases from RFC 2396
00242 
00243 
00244         self.checkJoin(RFC2396_BASE, 'g:h', 'g:h')
00245         self.checkJoin(RFC2396_BASE, 'g', 'http://a/b/c/g')
00246         self.checkJoin(RFC2396_BASE, './g', 'http://a/b/c/g')
00247         self.checkJoin(RFC2396_BASE, 'g/', 'http://a/b/c/g/')
00248         self.checkJoin(RFC2396_BASE, '/g', 'http://a/g')
00249         self.checkJoin(RFC2396_BASE, '//g', 'http://g')
00250         self.checkJoin(RFC2396_BASE, 'g?y', 'http://a/b/c/g?y')
00251         self.checkJoin(RFC2396_BASE, '#s', 'http://a/b/c/d;p?q#s')
00252         self.checkJoin(RFC2396_BASE, 'g#s', 'http://a/b/c/g#s')
00253         self.checkJoin(RFC2396_BASE, 'g?y#s', 'http://a/b/c/g?y#s')
00254         self.checkJoin(RFC2396_BASE, 'g;x', 'http://a/b/c/g;x')
00255         self.checkJoin(RFC2396_BASE, 'g;x?y#s', 'http://a/b/c/g;x?y#s')
00256         self.checkJoin(RFC2396_BASE, '.', 'http://a/b/c/')
00257         self.checkJoin(RFC2396_BASE, './', 'http://a/b/c/')
00258         self.checkJoin(RFC2396_BASE, '..', 'http://a/b/')
00259         self.checkJoin(RFC2396_BASE, '../', 'http://a/b/')
00260         self.checkJoin(RFC2396_BASE, '../g', 'http://a/b/g')
00261         self.checkJoin(RFC2396_BASE, '../..', 'http://a/')
00262         self.checkJoin(RFC2396_BASE, '../../', 'http://a/')
00263         self.checkJoin(RFC2396_BASE, '../../g', 'http://a/g')
00264         self.checkJoin(RFC2396_BASE, '', RFC2396_BASE)
00265         self.checkJoin(RFC2396_BASE, '../../../g', 'http://a/../g')
00266         self.checkJoin(RFC2396_BASE, '../../../../g', 'http://a/../../g')
00267         self.checkJoin(RFC2396_BASE, '/./g', 'http://a/./g')
00268         self.checkJoin(RFC2396_BASE, '/../g', 'http://a/../g')
00269         self.checkJoin(RFC2396_BASE, 'g.', 'http://a/b/c/g.')
00270         self.checkJoin(RFC2396_BASE, '.g', 'http://a/b/c/.g')
00271         self.checkJoin(RFC2396_BASE, 'g..', 'http://a/b/c/g..')
00272         self.checkJoin(RFC2396_BASE, '..g', 'http://a/b/c/..g')
00273         self.checkJoin(RFC2396_BASE, './../g', 'http://a/b/g')
00274         self.checkJoin(RFC2396_BASE, './g/.', 'http://a/b/c/g/')
00275         self.checkJoin(RFC2396_BASE, 'g/./h', 'http://a/b/c/g/h')
00276         self.checkJoin(RFC2396_BASE, 'g/../h', 'http://a/b/c/h')
00277         self.checkJoin(RFC2396_BASE, 'g;x=1/./y', 'http://a/b/c/g;x=1/y')
00278         self.checkJoin(RFC2396_BASE, 'g;x=1/../y', 'http://a/b/c/y')
00279         self.checkJoin(RFC2396_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x')
00280         self.checkJoin(RFC2396_BASE, 'g?y/../x', 'http://a/b/c/g?y/../x')
00281         self.checkJoin(RFC2396_BASE, 'g#s/./x', 'http://a/b/c/g#s/./x')
00282         self.checkJoin(RFC2396_BASE, 'g#s/../x', 'http://a/b/c/g#s/../x')

Here is the call graph for this function:

Definition at line 377 of file test_urlparse.py.

00377 
00378     def test_RFC2732(self):
00379         str_cases = [
00380             ('http://Test.python.org:5432/foo/', 'test.python.org', 5432),
00381             ('http://12.34.56.78:5432/foo/', '12.34.56.78', 5432),
00382             ('http://[::1]:5432/foo/', '::1', 5432),
00383             ('http://[dead:beef::1]:5432/foo/', 'dead:beef::1', 5432),
00384             ('http://[dead:beef::]:5432/foo/', 'dead:beef::', 5432),
00385             ('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:5432/foo/',
00386              'dead:beef:cafe:5417:affe:8fa3:deaf:feed', 5432),
00387             ('http://[::12.34.56.78]:5432/foo/', '::12.34.56.78', 5432),
00388             ('http://[::ffff:12.34.56.78]:5432/foo/',
00389              '::ffff:12.34.56.78', 5432),
00390             ('http://Test.python.org/foo/', 'test.python.org', None),
00391             ('http://12.34.56.78/foo/', '12.34.56.78', None),
00392             ('http://[::1]/foo/', '::1', None),
00393             ('http://[dead:beef::1]/foo/', 'dead:beef::1', None),
00394             ('http://[dead:beef::]/foo/', 'dead:beef::', None),
00395             ('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/',
00396              'dead:beef:cafe:5417:affe:8fa3:deaf:feed', None),
00397             ('http://[::12.34.56.78]/foo/', '::12.34.56.78', None),
00398             ('http://[::ffff:12.34.56.78]/foo/',
00399              '::ffff:12.34.56.78', None),
00400             ]
00401         def _encode(t):
00402             return t[0].encode('ascii'), t[1].encode('ascii'), t[2]
00403         bytes_cases = [_encode(x) for x in str_cases]
00404         for url, hostname, port in str_cases + bytes_cases:
00405             urlparsed = urllib.parse.urlparse(url)
00406             self.assertEqual((urlparsed.hostname, urlparsed.port) , (hostname, port))
00407 
00408         str_cases = [
00409                 'http://::12.34.56.78]/',
00410                 'http://[::1/foo/',
00411                 'ftp://[::1/foo/bad]/bad',
00412                 'http://[::1/foo/bad]/bad',
00413                 'http://[::ffff:12.34.56.78']
00414         bytes_cases = [x.encode('ascii') for x in str_cases]
00415         for invalid_url in str_cases + bytes_cases:
00416             self.assertRaises(ValueError, urllib.parse.urlparse, invalid_url)

Here is the call graph for this function:

Definition at line 283 of file test_urlparse.py.

00283 
00284     def test_RFC3986(self):
00285         # Test cases from RFC3986
00286         self.checkJoin(RFC3986_BASE, '?y','http://a/b/c/d;p?y')
00287         self.checkJoin(RFC2396_BASE, ';x', 'http://a/b/c/;x')
00288         self.checkJoin(RFC3986_BASE, 'g:h','g:h')
00289         self.checkJoin(RFC3986_BASE, 'g','http://a/b/c/g')
00290         self.checkJoin(RFC3986_BASE, './g','http://a/b/c/g')
00291         self.checkJoin(RFC3986_BASE, 'g/','http://a/b/c/g/')
00292         self.checkJoin(RFC3986_BASE, '/g','http://a/g')
00293         self.checkJoin(RFC3986_BASE, '//g','http://g')
00294         self.checkJoin(RFC3986_BASE, '?y','http://a/b/c/d;p?y')
00295         self.checkJoin(RFC3986_BASE, 'g?y','http://a/b/c/g?y')
00296         self.checkJoin(RFC3986_BASE, '#s','http://a/b/c/d;p?q#s')
00297         self.checkJoin(RFC3986_BASE, 'g#s','http://a/b/c/g#s')
00298         self.checkJoin(RFC3986_BASE, 'g?y#s','http://a/b/c/g?y#s')
00299         self.checkJoin(RFC3986_BASE, ';x','http://a/b/c/;x')
00300         self.checkJoin(RFC3986_BASE, 'g;x','http://a/b/c/g;x')
00301         self.checkJoin(RFC3986_BASE, 'g;x?y#s','http://a/b/c/g;x?y#s')
00302         self.checkJoin(RFC3986_BASE, '','http://a/b/c/d;p?q')
00303         self.checkJoin(RFC3986_BASE, '.','http://a/b/c/')
00304         self.checkJoin(RFC3986_BASE, './','http://a/b/c/')
00305         self.checkJoin(RFC3986_BASE, '..','http://a/b/')
00306         self.checkJoin(RFC3986_BASE, '../','http://a/b/')
00307         self.checkJoin(RFC3986_BASE, '../g','http://a/b/g')
00308         self.checkJoin(RFC3986_BASE, '../..','http://a/')
00309         self.checkJoin(RFC3986_BASE, '../../','http://a/')
00310         self.checkJoin(RFC3986_BASE, '../../g','http://a/g')
00311 
00312         #Abnormal Examples
00313 
00314         # The 'abnormal scenarios' are incompatible with RFC2986 parsing
00315         # Tests are here for reference.
00316 
00317         #self.checkJoin(RFC3986_BASE, '../../../g','http://a/g')
00318         #self.checkJoin(RFC3986_BASE, '../../../../g','http://a/g')
00319         #self.checkJoin(RFC3986_BASE, '/./g','http://a/g')
00320         #self.checkJoin(RFC3986_BASE, '/../g','http://a/g')
00321 
00322         self.checkJoin(RFC3986_BASE, 'g.','http://a/b/c/g.')
00323         self.checkJoin(RFC3986_BASE, '.g','http://a/b/c/.g')
00324         self.checkJoin(RFC3986_BASE, 'g..','http://a/b/c/g..')
00325         self.checkJoin(RFC3986_BASE, '..g','http://a/b/c/..g')
00326         self.checkJoin(RFC3986_BASE, './../g','http://a/b/g')
00327         self.checkJoin(RFC3986_BASE, './g/.','http://a/b/c/g/')
00328         self.checkJoin(RFC3986_BASE, 'g/./h','http://a/b/c/g/h')
00329         self.checkJoin(RFC3986_BASE, 'g/../h','http://a/b/c/h')
00330         self.checkJoin(RFC3986_BASE, 'g;x=1/./y','http://a/b/c/g;x=1/y')
00331         self.checkJoin(RFC3986_BASE, 'g;x=1/../y','http://a/b/c/y')
00332         self.checkJoin(RFC3986_BASE, 'g?y/./x','http://a/b/c/g?y/./x')
00333         self.checkJoin(RFC3986_BASE, 'g?y/../x','http://a/b/c/g?y/../x')
00334         self.checkJoin(RFC3986_BASE, 'g#s/./x','http://a/b/c/g#s/./x')
00335         self.checkJoin(RFC3986_BASE, 'g#s/../x','http://a/b/c/g#s/../x')
00336         #self.checkJoin(RFC3986_BASE, 'http:g','http:g') # strict parser
00337         self.checkJoin(RFC3986_BASE, 'http:g','http://a/b/c/g') #relaxed parser
00338 
00339         # Test for issue9721
00340         self.checkJoin('http://a/b/c/de', ';x','http://a/b/c/;x')

Here is the call graph for this function:

Definition at line 102 of file test_urlparse.py.

00102 
00103     def test_roundtrips(self):
00104         str_cases = [
00105             ('file:///tmp/junk.txt',
00106              ('file', '', '/tmp/junk.txt', '', '', ''),
00107              ('file', '', '/tmp/junk.txt', '', '')),
00108             ('imap://mail.python.org/mbox1',
00109              ('imap', 'mail.python.org', '/mbox1', '', '', ''),
00110              ('imap', 'mail.python.org', '/mbox1', '', '')),
00111             ('mms://wms.sys.hinet.net/cts/Drama/09006251100.asf',
00112              ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf',
00113               '', '', ''),
00114              ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf',
00115               '', '')),
00116             ('nfs://server/path/to/file.txt',
00117              ('nfs', 'server', '/path/to/file.txt', '', '', ''),
00118              ('nfs', 'server', '/path/to/file.txt', '', '')),
00119             ('svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/',
00120              ('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/',
00121               '', '', ''),
00122              ('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/',
00123               '', '')),
00124             ('git+ssh://git@github.com/user/project.git',
00125             ('git+ssh', 'git@github.com','/user/project.git',
00126              '','',''),
00127             ('git+ssh', 'git@github.com','/user/project.git',
00128              '', '')),
00129             ]
00130         def _encode(t):
00131             return (t[0].encode('ascii'),
00132                     tuple(x.encode('ascii') for x in t[1]),
00133                     tuple(x.encode('ascii') for x in t[2]))
00134         bytes_cases = [_encode(x) for x in str_cases]
00135         for url, parsed, split in str_cases + bytes_cases:
00136             self.checkRoundtrips(url, parsed, split)

Here is the call graph for this function:

Definition at line 730 of file test_urlparse.py.

00730 
00731     def test_splitnport(self):
00732         # Normal cases are exercised by other tests; ensure that we also
00733         # catch cases with no port specified. (testcase ensuring coverage)
00734         result = urllib.parse.splitnport('parrot:88')
00735         self.assertEqual(result, ('parrot', 88))
00736         result = urllib.parse.splitnport('parrot')
00737         self.assertEqual(result, ('parrot', -1))
00738         result = urllib.parse.splitnport('parrot', 55)
00739         self.assertEqual(result, ('parrot', 55))
00740         result = urllib.parse.splitnport('parrot:')
00741         self.assertEqual(result, ('parrot', None))

Here is the call graph for this function:

Definition at line 742 of file test_urlparse.py.

00742 
00743     def test_splitquery(self):
00744         # Normal cases are exercised by other tests; ensure that we also
00745         # catch cases with no port specified (testcase ensuring coverage)
00746         result = urllib.parse.splitquery('http://python.org/fake?foo=bar')
00747         self.assertEqual(result, ('http://python.org/fake', 'foo=bar'))
00748         result = urllib.parse.splitquery('http://python.org/fake?foo=bar?')
00749         self.assertEqual(result, ('http://python.org/fake?foo=bar', ''))
00750         result = urllib.parse.splitquery('http://python.org/fake')
00751         self.assertEqual(result, ('http://python.org/fake', None))

Here is the call graph for this function:

Definition at line 752 of file test_urlparse.py.

00752 
00753     def test_splitvalue(self):
00754         # Normal cases are exercised by other tests; test pathological cases
00755         # with no key/value pairs. (testcase ensuring coverage)
00756         result = urllib.parse.splitvalue('foo=bar')
00757         self.assertEqual(result, ('foo', 'bar'))
00758         result = urllib.parse.splitvalue('foo=')
00759         self.assertEqual(result, ('foo', ''))
00760         result = urllib.parse.splitvalue('foobar')
00761         self.assertEqual(result, ('foobar', None))

Here is the call graph for this function:

Definition at line 762 of file test_urlparse.py.

00762 
00763     def test_to_bytes(self):
00764         result = urllib.parse.to_bytes('http://www.python.org')
00765         self.assertEqual(result, 'http://www.python.org')
00766         self.assertRaises(UnicodeError, urllib.parse.to_bytes,
00767                           'http://www.python.org/medi\u00e6val')

Here is the call graph for this function:

Definition at line 182 of file test_urlparse.py.

00182 
00183     def test_unparse_parse(self):
00184         str_cases = ['Python', './Python','x-newscheme://foo.com/stuff','x://y','x:/y','x:/','/',]
00185         bytes_cases = [x.encode('ascii') for x in str_cases]
00186         for u in str_cases + bytes_cases:
00187             self.assertEqual(urllib.parse.urlunsplit(urllib.parse.urlsplit(u)), u)
00188             self.assertEqual(urllib.parse.urlunparse(urllib.parse.urlparse(u)), u)

Here is the call graph for this function:

Definition at line 788 of file test_urlparse.py.

00788 
00789     def test_unquote_to_bytes(self):
00790         result = urllib.parse.unquote_to_bytes('abc%20def')
00791         self.assertEqual(result, b'abc def')
00792         result = urllib.parse.unquote_to_bytes('')
00793         self.assertEqual(result, b'')

Here is the call graph for this function:

Definition at line 417 of file test_urlparse.py.

00417 
00418     def test_urldefrag(self):
00419         str_cases = [
00420             ('http://python.org#frag', 'http://python.org', 'frag'),
00421             ('http://python.org', 'http://python.org', ''),
00422             ('http://python.org/#frag', 'http://python.org/', 'frag'),
00423             ('http://python.org/', 'http://python.org/', ''),
00424             ('http://python.org/?q#frag', 'http://python.org/?q', 'frag'),
00425             ('http://python.org/?q', 'http://python.org/?q', ''),
00426             ('http://python.org/p#frag', 'http://python.org/p', 'frag'),
00427             ('http://python.org/p?q', 'http://python.org/p?q', ''),
00428             (RFC1808_BASE, 'http://a/b/c/d;p?q', 'f'),
00429             (RFC2396_BASE, 'http://a/b/c/d;p?q', ''),
00430         ]
00431         def _encode(t):
00432             return type(t)(x.encode('ascii') for x in t)
00433         bytes_cases = [_encode(x) for x in str_cases]
00434         for url, defrag, frag in str_cases + bytes_cases:
00435             result = urllib.parse.urldefrag(url)
00436             self.assertEqual(result.geturl(), url)
00437             self.assertEqual(result, (defrag, frag))
00438             self.assertEqual(result.url, defrag)
00439             self.assertEqual(result.fragment, frag)

Here is the call graph for this function:

Definition at line 768 of file test_urlparse.py.

00768 
00769     def test_urlencode_sequences(self):
00770         # Other tests incidentally urlencode things; test non-covered cases:
00771         # Sequence and object values.
00772         result = urllib.parse.urlencode({'a': [1, 2], 'b': (3, 4, 5)}, True)
00773         self.assertEqual(result, 'a=1&a=2&b=3&b=4&b=5')
00774 
00775         class Trivial:
00776             def __str__(self):
00777                 return 'trivial'
00778 
00779         result = urllib.parse.urlencode({'a': Trivial()}, True)
00780         self.assertEqual(result, 'a=trivial')

Here is the call graph for this function:

Definition at line 341 of file test_urlparse.py.

00341 
00342     def test_urljoins(self):
00343         self.checkJoin(SIMPLE_BASE, 'g:h','g:h')
00344         self.checkJoin(SIMPLE_BASE, 'http:g','http://a/b/c/g')
00345         self.checkJoin(SIMPLE_BASE, 'http:','http://a/b/c/d')
00346         self.checkJoin(SIMPLE_BASE, 'g','http://a/b/c/g')
00347         self.checkJoin(SIMPLE_BASE, './g','http://a/b/c/g')
00348         self.checkJoin(SIMPLE_BASE, 'g/','http://a/b/c/g/')
00349         self.checkJoin(SIMPLE_BASE, '/g','http://a/g')
00350         self.checkJoin(SIMPLE_BASE, '//g','http://g')
00351         self.checkJoin(SIMPLE_BASE, '?y','http://a/b/c/d?y')
00352         self.checkJoin(SIMPLE_BASE, 'g?y','http://a/b/c/g?y')
00353         self.checkJoin(SIMPLE_BASE, 'g?y/./x','http://a/b/c/g?y/./x')
00354         self.checkJoin(SIMPLE_BASE, '.','http://a/b/c/')
00355         self.checkJoin(SIMPLE_BASE, './','http://a/b/c/')
00356         self.checkJoin(SIMPLE_BASE, '..','http://a/b/')
00357         self.checkJoin(SIMPLE_BASE, '../','http://a/b/')
00358         self.checkJoin(SIMPLE_BASE, '../g','http://a/b/g')
00359         self.checkJoin(SIMPLE_BASE, '../..','http://a/')
00360         self.checkJoin(SIMPLE_BASE, '../../g','http://a/g')
00361         self.checkJoin(SIMPLE_BASE, '../../../g','http://a/../g')
00362         self.checkJoin(SIMPLE_BASE, './../g','http://a/b/g')
00363         self.checkJoin(SIMPLE_BASE, './g/.','http://a/b/c/g/')
00364         self.checkJoin(SIMPLE_BASE, '/./g','http://a/./g')
00365         self.checkJoin(SIMPLE_BASE, 'g/./h','http://a/b/c/g/h')
00366         self.checkJoin(SIMPLE_BASE, 'g/../h','http://a/b/c/h')
00367         self.checkJoin(SIMPLE_BASE, 'http:g','http://a/b/c/g')
00368         self.checkJoin(SIMPLE_BASE, 'http:','http://a/b/c/d')
00369         self.checkJoin(SIMPLE_BASE, 'http:?y','http://a/b/c/d?y')
00370         self.checkJoin(SIMPLE_BASE, 'http:g?y','http://a/b/c/g?y')
00371         self.checkJoin(SIMPLE_BASE, 'http:g?y/./x','http://a/b/c/g?y/./x')
00372         self.checkJoin('http:///', '..','http:///')
00373         self.checkJoin('', 'http://a/b/c/g?y/./x','http://a/b/c/g?y/./x')
00374         self.checkJoin('', 'http://a/./g', 'http://a/./g')
00375         self.checkJoin('svn://pathtorepo/dir1', 'dir2', 'svn://pathtorepo/dir2')
00376         self.checkJoin('svn+ssh://pathtorepo/dir1', 'dir2', 'svn+ssh://pathtorepo/dir2')

Here is the call graph for this function:

Definition at line 440 of file test_urlparse.py.

00440 
00441     def test_urlsplit_attributes(self):
00442         url = "HTTP://WWW.PYTHON.ORG/doc/#frag"
00443         p = urllib.parse.urlsplit(url)
00444         self.assertEqual(p.scheme, "http")
00445         self.assertEqual(p.netloc, "WWW.PYTHON.ORG")
00446         self.assertEqual(p.path, "/doc/")
00447         self.assertEqual(p.query, "")
00448         self.assertEqual(p.fragment, "frag")
00449         self.assertEqual(p.username, None)
00450         self.assertEqual(p.password, None)
00451         self.assertEqual(p.hostname, "www.python.org")
00452         self.assertEqual(p.port, None)
00453         # geturl() won't return exactly the original URL in this case
00454         # since the scheme is always case-normalized
00455         # We handle this by ignoring the first 4 characters of the URL
00456         self.assertEqual(p.geturl()[4:], url[4:])
00457 
00458         url = "http://User:Pass@www.python.org:080/doc/?query=yes#frag"
00459         p = urllib.parse.urlsplit(url)
00460         self.assertEqual(p.scheme, "http")
00461         self.assertEqual(p.netloc, "User:Pass@www.python.org:080")
00462         self.assertEqual(p.path, "/doc/")
00463         self.assertEqual(p.query, "query=yes")
00464         self.assertEqual(p.fragment, "frag")
00465         self.assertEqual(p.username, "User")
00466         self.assertEqual(p.password, "Pass")
00467         self.assertEqual(p.hostname, "www.python.org")
00468         self.assertEqual(p.port, 80)
00469         self.assertEqual(p.geturl(), url)
00470 
00471         # Addressing issue1698, which suggests Username can contain
00472         # "@" characters.  Though not RFC compliant, many ftp sites allow
00473         # and request email addresses as usernames.
00474 
00475         url = "http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag"
00476         p = urllib.parse.urlsplit(url)
00477         self.assertEqual(p.scheme, "http")
00478         self.assertEqual(p.netloc, "User@example.com:Pass@www.python.org:080")
00479         self.assertEqual(p.path, "/doc/")
00480         self.assertEqual(p.query, "query=yes")
00481         self.assertEqual(p.fragment, "frag")
00482         self.assertEqual(p.username, "User@example.com")
00483         self.assertEqual(p.password, "Pass")
00484         self.assertEqual(p.hostname, "www.python.org")
00485         self.assertEqual(p.port, 80)
00486         self.assertEqual(p.geturl(), url)
00487 
00488         # And check them all again, only with bytes this time
00489         url = b"HTTP://WWW.PYTHON.ORG/doc/#frag"
00490         p = urllib.parse.urlsplit(url)
00491         self.assertEqual(p.scheme, b"http")
00492         self.assertEqual(p.netloc, b"WWW.PYTHON.ORG")
00493         self.assertEqual(p.path, b"/doc/")
00494         self.assertEqual(p.query, b"")
00495         self.assertEqual(p.fragment, b"frag")
00496         self.assertEqual(p.username, None)
00497         self.assertEqual(p.password, None)
00498         self.assertEqual(p.hostname, b"www.python.org")
00499         self.assertEqual(p.port, None)
00500         self.assertEqual(p.geturl()[4:], url[4:])
00501 
00502         url = b"http://User:Pass@www.python.org:080/doc/?query=yes#frag"
00503         p = urllib.parse.urlsplit(url)
00504         self.assertEqual(p.scheme, b"http")
00505         self.assertEqual(p.netloc, b"User:Pass@www.python.org:080")
00506         self.assertEqual(p.path, b"/doc/")
00507         self.assertEqual(p.query, b"query=yes")
00508         self.assertEqual(p.fragment, b"frag")
00509         self.assertEqual(p.username, b"User")
00510         self.assertEqual(p.password, b"Pass")
00511         self.assertEqual(p.hostname, b"www.python.org")
00512         self.assertEqual(p.port, 80)
00513         self.assertEqual(p.geturl(), url)
00514 
00515         url = b"http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag"
00516         p = urllib.parse.urlsplit(url)
00517         self.assertEqual(p.scheme, b"http")
00518         self.assertEqual(p.netloc, b"User@example.com:Pass@www.python.org:080")
00519         self.assertEqual(p.path, b"/doc/")
00520         self.assertEqual(p.query, b"query=yes")
00521         self.assertEqual(p.fragment, b"frag")
00522         self.assertEqual(p.username, b"User@example.com")
00523         self.assertEqual(p.password, b"Pass")
00524         self.assertEqual(p.hostname, b"www.python.org")
00525         self.assertEqual(p.port, 80)
00526         self.assertEqual(p.geturl(), url)

Here is the call graph for this function:

Definition at line 629 of file test_urlparse.py.

00629 
00630     def test_usingsys(self):
00631         # Issue 3314: sys module is used in the error
00632         self.assertRaises(TypeError, urllib.parse.urlencode, "foo")

Here is the call graph for this function:

Definition at line 594 of file test_urlparse.py.

00594 
00595     def test_withoutscheme(self):
00596         # Test urlparse without scheme
00597         # Issue 754016: urlparse goes wrong with IP:port without scheme
00598         # RFC 1808 specifies that netloc should start with //, urlparse expects
00599         # the same, otherwise it classifies the portion of url as path.
00600         self.assertEqual(urllib.parse.urlparse("path"),
00601                 ('','','path','','',''))
00602         self.assertEqual(urllib.parse.urlparse("//www.python.org:80"),
00603                 ('','www.python.org:80','','','',''))
00604         self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"),
00605                 ('http','www.python.org:80','','','',''))
00606         # Repeat for bytes input
00607         self.assertEqual(urllib.parse.urlparse(b"path"),
00608                 (b'',b'',b'path',b'',b'',b''))
00609         self.assertEqual(urllib.parse.urlparse(b"//www.python.org:80"),
00610                 (b'',b'www.python.org:80',b'',b'',b'',b''))
00611         self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"),
00612                 (b'http',b'www.python.org:80',b'',b'',b'',b''))

Here is the call graph for this function:


The documentation for this class was generated from the following file: