MCPcopy Create free account
hub / github.com/python-websockets/websockets / test_port

Method test_port

tests/test_client.py:130–144  ·  view source on GitHub ↗

connect() uses the port from the URI or the default port.

(self)

Source from the content-addressed store, hash-verified

128 self.assertEqual(request.path, "/endpoint?test=1")
129
130 def test_port(self):
131 """connect() uses the port from the URI or the default port."""
132 for uri, host in [
133 ("ws://example.com/", "example.com"),
134 ("ws://example.com:80/", "example.com"),
135 ("ws://example.com:8080/", "example.com:8080"),
136 ("wss://example.com/", "example.com"),
137 ("wss://example.com:443/", "example.com"),
138 ("wss://example.com:8443/", "example.com:8443"),
139 ]:
140 with self.subTest(uri=uri):
141 client = ClientProtocol(parse_uri(uri))
142 request = client.connect()
143
144 self.assertEqual(request.headers["Host"], host)
145
146 def test_user_info(self):
147 """connect() perfoms HTTP Basic Authentication with user info from the URI."""

Callers

nothing calls this directly

Calls 3

connectMethod · 0.95
parse_uriFunction · 0.90
ClientProtocolClass · 0.85

Tested by

no test coverage detected