Skip to content

Commit d22af7f

Browse files
committed
formatting
1 parent 2392a05 commit d22af7f

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

tests/contrib/graphene/test_graphene.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,6 @@ def test_schema_execute(test_schema, test_source_str):
8989
assert result.data == {"patron": {"id": "1", "name": "Syrus", "age": 27}}
9090

9191

92-
@pytest.mark.snapshot(
93-
ignores=["meta.events", "meta.error.stack"], variants={"v2": graphene.VERSION < (3,), "": graphene.VERSION >= (3,)}
94-
)
95-
@pytest.mark.snapshot
96-
def test_schema_failing_extensions():
97-
schema = graphene.Schema(query=Query)
98-
os.environ["DD_TRACE_GRAPHQL_ERROR_EXTENSIONS"] = "code, status"
99-
100-
query_string = '{ user(id: "999") }'
101-
result = schema.execute(query_string)
102-
assert result.errors
103-
104-
10592
@pytest.mark.asyncio
10693
@pytest.mark.snapshot(token="tests.contrib.graphene.test_graphene.test_schema_execute")
10794
@pytest.mark.skipif(graphene.VERSION < (3, 0, 0), reason="execute_async is only supported in graphene>=3.0")
@@ -127,6 +114,15 @@ async def test_schema_execute_async_with_resolvers(test_schema, test_source_str,
127114
assert result.data == {"patron": {"id": "1", "name": "Syrus", "age": 27}}
128115

129116

117+
@pytest.mark.snapshot
118+
def test_schema_failing_extensions(test_schema, test_source_str, enable_graphql_resolvers):
119+
schema = graphene.Schema(query=Query)
120+
os.environ["DD_TRACE_GRAPHQL_ERROR_EXTENSIONS"] = "code, status"
121+
query_string = '{ user(id: "999") }'
122+
result = schema.execute(query_string)
123+
assert result.errors
124+
125+
130126
@pytest.mark.snapshot(
131127
ignores=["meta.events", "meta.error.stack"], variants={"v2": graphene.VERSION < (3,), "": graphene.VERSION >= (3,)}
132128
)

tests/contrib/graphql/test_graphql.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22

33
import graphql
4+
from graphql import build_schema
5+
from graphql import graphql_sync
46
import pytest
57

68
from ddtrace.contrib.internal.graphql.patch import _graphql_version as graphql_version
@@ -75,7 +77,6 @@ async def test_graphql_with_traced_resolver(test_schema, test_source_str, snapsh
7577
assert result.data == {"hello": "friend"}
7678

7779

78-
7980
def resolve_fail(root, info):
8081
undefined_var = None
8182
return undefined_var.property
@@ -101,13 +102,16 @@ def test_graphql_fail(enable_graphql_resolvers):
101102
"""
102103

103104
test_schema = build_schema(schema_definition)
104-
result = graphql_sync(test_schema, query, root_value=None, field_resolver=lambda _type, _field: resolvers[_type.name][_field.name])
105+
result = graphql_sync(
106+
test_schema, query, root_value=None, field_resolver=lambda _type, _field: resolvers[_type.name][_field.name]
107+
)
105108

106109
assert result.errors is not None
107110
assert len(result.errors) == 1
108111
assert isinstance(result.errors[0], graphql.error.GraphQLError)
109112
assert "'NoneType' object has no attribute 'name'" in result.errors[0].message
110113

114+
111115
@pytest.mark.asyncio
112116
async def test_graphql_error(test_schema, snapshot_context):
113117
with snapshot_context(ignores=["meta.error.type", "meta.error.message", "meta.events"]):

0 commit comments

Comments
 (0)