Skip to content

Commit 989970f

Browse files
committed
Make tests work with GraphQL-core 3.2.0rc2
This fix aligns to some changes in GraphQL-core 3.2 which reflect changes in GraphQL.js 16: - type resolvers must return only names - doesn't print trailing newlines any more - different wording of some error messages
1 parent 0a54094 commit 989970f

File tree

8 files changed

+10
-17
lines changed

8 files changed

+10
-17
lines changed

examples/starwars_relay/tests/test_objectidentification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
def test_str_schema(snapshot):
12-
snapshot.assert_match(str(schema))
12+
snapshot.assert_match(str(schema).rstrip() + "\n")
1313

1414

1515
def test_correctly_fetches_id_name_rebels(snapshot):

graphene/relay/tests/test_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def test_node_field_only_lazy_type_wrong():
171171

172172

173173
def test_str_schema():
174-
assert str(schema) == dedent(
174+
assert str(schema).rstrip() + "\n" == dedent(
175175
'''
176176
schema {
177177
query: RootQuery

graphene/relay/tests/test_node_custom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class RootQuery(ObjectType):
5454

5555

5656
def test_str_schema_correct():
57-
assert str(schema) == dedent(
57+
assert str(schema).rstrip() + "\n" == dedent(
5858
'''
5959
schema {
6060
query: RootQuery

graphene/types/schema.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,7 @@ def resolve_type(self, resolve_type_func, type_name, root, info, _type):
381381
return default_type_resolver(root, info, return_type)
382382

383383
if inspect.isclass(type_) and issubclass(type_, ObjectType):
384-
graphql_type = self.get(type_._meta.name)
385-
assert graphql_type, f"Can't find type {type_._meta.name} in schema"
386-
assert (
387-
graphql_type.graphene_type == type_
388-
), f"The type {type_} does not match with the associated graphene type {graphql_type.graphene_type}."
389-
return graphql_type
384+
return type_._meta.name
390385

391386
return type_
392387

graphene/types/tests/test_enum.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def resolve_color(_, info):
251251

252252
schema = Schema(query=Query)
253253

254-
assert str(schema) == dedent(
254+
assert str(schema).rstrip() + "\n" == dedent(
255255
'''\
256256
type Query {
257257
color: Color!
@@ -345,10 +345,8 @@ def resolve_color(_, info):
345345

346346
results = schema.execute("query { color }")
347347
assert results.errors
348-
assert (
349-
results.errors[0].message
350-
== "Expected a value of type 'Color' but received: 'BLACK'"
351-
)
348+
message = results.errors[0].message
349+
assert "Expected" in message and "Color" in message and "BLACK" in message
352350

353351

354352
def test_field_enum_argument():

graphene/types/tests/test_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_schema_get_type_error():
4343

4444
def test_schema_str():
4545
schema = Schema(Query)
46-
assert str(schema) == dedent(
46+
assert str(schema).rstrip() + "\n" == dedent(
4747
"""
4848
type Query {
4949
inner: MyOtherType

graphene/types/union.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ def resolve_type(cls, instance, info):
7272
from .objecttype import ObjectType # NOQA
7373

7474
if isinstance(instance, ObjectType):
75-
return type(instance)
75+
return instance._meta.name

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def run_tests(self):
8282
keywords="api graphql protocol rest relay graphene",
8383
packages=find_packages(exclude=["examples*"]),
8484
install_requires=[
85-
"graphql-core~=3.1.2",
85+
"graphql-core>=3.1.2,<3.3",
8686
"graphql-relay>=3.0,<4",
8787
"aniso8601>=8,<10",
8888
],

0 commit comments

Comments
 (0)