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

Method test_connect

tests/test_client.py:103–121  ·  view source on GitHub ↗

connect() creates an opening handshake request.

(self, _generate_key)

Source from the content-addressed store, hash-verified

101
102 @patch("websockets.client.generate_key", return_value=KEY)
103 def test_connect(self, _generate_key):
104 """connect() creates an opening handshake request."""
105 client = ClientProtocol(URI)
106 request = client.connect()
107
108 self.assertIsInstance(request, Request)
109 self.assertEqual(request.path, "/test")
110 self.assertEqual(
111 request.headers,
112 Headers(
113 {
114 "Host": "example.com",
115 "Upgrade": "websocket",
116 "Connection": "Upgrade",
117 "Sec-WebSocket-Key": KEY,
118 "Sec-WebSocket-Version": "13",
119 }
120 ),
121 )
122
123 def test_path(self):
124 """connect() uses the path from the URI."""

Callers

nothing calls this directly

Calls 3

connectMethod · 0.95
HeadersClass · 0.90
ClientProtocolClass · 0.85

Tested by

no test coverage detected