MCPcopy Index your code
hub / github.com/python/cpython / test_attributes_bad_port

Method test_attributes_bad_port

Lib/test/test_urlparse.py:1023–1035  ·  view source on GitHub ↗

Check handling of invalid ports.

(self, bytes, parse, port)

Source from the content-addressed store, hash-verified

1021 @support.subTests('parse', (urllib.parse.urlsplit, urllib.parse.urlparse))
1022 @support.subTests('port', ("foo", "1.5", "-1", "0x10", "-0", "1_1", " 1", "1 ", "६"))
1023 def test_attributes_bad_port(self, bytes, parse, port):
1024 """Check handling of invalid ports."""
1025 netloc = "www.example.net:" + port
1026 url = "http://" + netloc + "/"
1027 if bytes:
1028 if not (netloc.isascii() and port.isascii()):
1029 self.skipTest('non-ASCII bytes')
1030 netloc = str_encode(netloc)
1031 url = str_encode(url)
1032 p = parse(url)
1033 self.assertEqual(p.netloc, netloc)
1034 with self.assertRaises(ValueError):
1035 p.port
1036
1037 @support.subTests('bytes', (False, True))
1038 @support.subTests('parse', (urllib.parse.urlsplit, urllib.parse.urlparse))

Callers

nothing calls this directly

Calls 6

str_encodeFunction · 0.85
isasciiMethod · 0.80
skipTestMethod · 0.80
parseFunction · 0.50
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected