async def test_single_result_pre_execution_error(ws: WebSocketClient):
    """Test that single-result-operations which raise exceptions
    behave in the same way as streaming operations.
    """
    process_errors = Mock()
    with patch.object(Schema, "process_errors", process_errors):
        await ws.send_message(
            {
                "id": "sub1",
                "type": "subscribe",
                "payload": {
                    "query": "query { IDontExist }",
                },
            }
        )

        error_message: ErrorMessage = await ws.receive_json()
        assert error_message["type"] == "error"
        assert error_message["id"] == "sub1"
        assert len(error_message["payload"]) == 1
        assert "message" in error_message["payload"][0]
        assert (
            error_message["payload"][0]["message"]
            == "Cannot query field 'IDontExist' on type 'Query'."
        )
        process_errors.assert_called_once()
Test that single-result-operations which raise exceptions
    behave in the same way as streaming operations.
    
tests/websockets/test_graphql_transport_ws.py