diff --git a/tests/schema/test_execution_errors.py b/tests/schema/test_execution_errors.py index e4fa50b2fe..513904e4b6 100644 --- a/tests/schema/test_execution_errors.py +++ b/tests/schema/test_execution_errors.py @@ -38,10 +38,13 @@ async def name(self) -> str: } """ - with pytest.raises(RuntimeError) as e: - schema.execute_sync(query) - - assert e.value.args[0] == "GraphQL execution failed to complete synchronously." + result = schema.execute_sync(query) + assert len(result.errors) == 1 + assert isinstance(result.errors[0].original_error, RuntimeError) + assert ( + result.errors[0].message + == "GraphQL execution failed to complete synchronously." + ) @pytest.mark.asyncio diff --git a/tests/types/test_execution.py b/tests/types/test_execution.py index a191c63dc8..35cfdfc682 100644 --- a/tests/types/test_execution.py +++ b/tests/types/test_execution.py @@ -1,4 +1,3 @@ -import pytest import strawberry from strawberry.extensions import SchemaExtension @@ -150,8 +149,10 @@ def on_operation(self): schema = strawberry.Schema(Query, extensions=[MyExtension]) - with pytest.raises(RuntimeError): - schema.execute_sync("mutation { myMutation }") + result = schema.execute_sync("mutation { myMutation }") + assert len(result.errors) == 1 + assert isinstance(result.errors[0].original_error, RuntimeError) + assert result.errors[0].message == "No GraphQL document available" def test_error_when_accessing_operation_type_with_invalid_operation_name(): @@ -165,5 +166,7 @@ def on_parse(self): schema = strawberry.Schema(Query, extensions=[MyExtension]) - with pytest.raises(RuntimeError): - schema.execute_sync("query { ping }", operation_name="MyQuery") + result = schema.execute_sync("query { ping }", operation_name="MyQuery") + assert len(result.errors) == 1 + assert isinstance(result.errors[0].original_error, RuntimeError) + assert result.errors[0].message == "Can't get GraphQL operation type"