def test_parse_no_compress_frame_single() -> None: parser_no_compress = WebSocketReader(out, 0, compress=False) with pytest.raises(WebSocketError) as ctx: parser_no_compress.parse_frame(struct.pack( '!BB', 0b11000001, 0b00000001)) parser_no_compress.parse_frame(b'1') assert ctx.value.code == WSCloseCode.PROTOCOL_ERROR
def test_parse_no_compress_frame_single() -> None: parser_no_compress = WebSocketReader(out, 0, compress=False) with pytest.raises(WebSocketError) as ctx: parser_no_compress.parse_frame( struct.pack("!BB", 0b11000001, 0b00000001)) parser_no_compress.parse_frame(b"1") assert ctx.value.code == WSCloseCode.PROTOCOL_ERROR
def parser(out): return WebSocketReader(out)
def parser_no_compress(out): return WebSocketReader(out, compress=False)
def parser(out: Any): return WebSocketReader(out, 4 * 1024 * 1024)
def test_compressed_msg_too_large(out: Any) -> None: parser = WebSocketReader(out, 256, compress=True) data = build_frame(b"aaa" * 256, WSMsgType.TEXT, compress=True) with pytest.raises(WebSocketError) as ctx: parser._feed_data(data) assert ctx.value.code == WSCloseCode.MESSAGE_TOO_BIG
def test_compressed_msg_too_large(out) -> None: parser = WebSocketReader(out, 256, compress=True) data = build_frame(b'aaa'*256, WSMsgType.TEXT, compress=True) with pytest.raises(WebSocketError) as ctx: parser._feed_data(data) assert ctx.value.code == WSCloseCode.MESSAGE_TOO_BIG
def test_msg_too_large_not_fin(out) -> None: parser = WebSocketReader(out, 256, compress=False) data = build_frame(b'text'*256, WSMsgType.TEXT, is_fin=False) with pytest.raises(WebSocketError) as ctx: parser._feed_data(data) assert ctx.value.code == WSCloseCode.MESSAGE_TOO_BIG
def function2564(function2574): return WebSocketReader(function2574)