Skip to content

Commit 76c130f

Browse files
pgjonesKriechi
authored andcommitted
Fix incompatibility in tests with the latest h11
The latest h11 events are frozen dataclasses and hence the headers can't be overwritten.
1 parent 1f87afc commit 76c130f

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

test/test_server.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -205,30 +205,24 @@ def _make_handshake(
205205
def test_handshake() -> None:
206206
response, nonce = _make_handshake([])
207207

208-
response.headers = sorted(response.headers) # For test determinism
209-
assert response == h11.InformationalResponse(
210-
status_code=101,
211-
headers=[
212-
(b"connection", b"Upgrade"),
213-
(b"sec-websocket-accept", generate_accept_token(nonce)),
214-
(b"upgrade", b"WebSocket"),
215-
],
216-
)
208+
assert response.status_code == 101
209+
assert sorted(response.headers) == [
210+
(b"connection", b"Upgrade"),
211+
(b"sec-websocket-accept", generate_accept_token(nonce)),
212+
(b"upgrade", b"WebSocket"),
213+
]
217214

218215

219216
def test_handshake_extra_headers() -> None:
220217
response, nonce = _make_handshake([], accept_headers=[(b"X-Foo", b"bar")])
221218

222-
response.headers = sorted(response.headers) # For test determinism
223-
assert response == h11.InformationalResponse(
224-
status_code=101,
225-
headers=[
226-
(b"connection", b"Upgrade"),
227-
(b"sec-websocket-accept", generate_accept_token(nonce)),
228-
(b"upgrade", b"WebSocket"),
229-
(b"x-foo", b"bar"),
230-
],
231-
)
219+
assert response.status_code == 101
220+
assert sorted(response.headers) == [
221+
(b"connection", b"Upgrade"),
222+
(b"sec-websocket-accept", generate_accept_token(nonce)),
223+
(b"upgrade", b"WebSocket"),
224+
(b"x-foo", b"bar"),
225+
]
232226

233227

234228
@pytest.mark.parametrize("accept_subprotocol", ["one", "two"])

0 commit comments

Comments
 (0)