MCPcopy Index your code
hub / github.com/python-websockets/websockets / test_build_host

Method test_build_host

tests/test_headers.py:8–35  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6
7class HeadersTests(unittest.TestCase):
8 def test_build_host(self):
9 for (host, port, secure), (result, result_with_port) in [
10 (("localhost", 80, False), ("localhost", "localhost:80")),
11 (("localhost", 8000, False), ("localhost:8000", "localhost:8000")),
12 (("localhost", 443, True), ("localhost", "localhost:443")),
13 (("localhost", 8443, True), ("localhost:8443", "localhost:8443")),
14 (("example.com", 80, False), ("example.com", "example.com:80")),
15 (("example.com", 8000, False), ("example.com:8000", "example.com:8000")),
16 (("example.com", 443, True), ("example.com", "example.com:443")),
17 (("example.com", 8443, True), ("example.com:8443", "example.com:8443")),
18 (("127.0.0.1", 80, False), ("127.0.0.1", "127.0.0.1:80")),
19 (("127.0.0.1", 8000, False), ("127.0.0.1:8000", "127.0.0.1:8000")),
20 (("127.0.0.1", 443, True), ("127.0.0.1", "127.0.0.1:443")),
21 (("127.0.0.1", 8443, True), ("127.0.0.1:8443", "127.0.0.1:8443")),
22 (("::1", 80, False), ("[::1]", "[::1]:80")),
23 (("::1", 8000, False), ("[::1]:8000", "[::1]:8000")),
24 (("::1", 443, True), ("[::1]", "[::1]:443")),
25 (("::1", 8443, True), ("[::1]:8443", "[::1]:8443")),
26 ]:
27 with self.subTest(host=host, port=port, secure=secure):
28 self.assertEqual(
29 build_host(host, port, secure),
30 result,
31 )
32 self.assertEqual(
33 build_host(host, port, secure, always_include_port=True),
34 result_with_port,
35 )
36
37 def test_parse_connection(self):
38 for header, parsed in [

Callers

nothing calls this directly

Calls 1

build_hostFunction · 0.85

Tested by

no test coverage detected