Skip to content

Commit ba29de5

Browse files
committed
Improved assertion messages. Fixed #400
1 parent 51b72d8 commit ba29de5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

graphene/types/typemap.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def resolve_type(resolve_type_func, map, type_name, root, context, info):
4343

4444
if inspect.isclass(_type) and issubclass(_type, ObjectType):
4545
graphql_type = map.get(_type._meta.name)
46-
assert graphql_type and graphql_type.graphene_type == _type
46+
assert graphql_type and graphql_type.graphene_type == _type, (
47+
'The type {} does not match with the associated graphene type {}.'
48+
).format(_type, graphql_type.graphene_type)
4749
return graphql_type
4850

4951
return _type
@@ -71,7 +73,9 @@ def graphene_reducer(self, map, type):
7173
if type._meta.name in map:
7274
_type = map[type._meta.name]
7375
if isinstance(_type, GrapheneGraphQLType):
74-
assert _type.graphene_type == type
76+
assert _type.graphene_type == type, (
77+
'Found different types with the same name in the schema: {}, {}.'
78+
).format(_type.graphene_type, type)
7579
return map
7680

7781
if issubclass(type, ObjectType):
@@ -132,7 +136,9 @@ def construct_objecttype(self, map, type):
132136
if type._meta.name in map:
133137
_type = map[type._meta.name]
134138
if isinstance(_type, GrapheneGraphQLType):
135-
assert _type.graphene_type == type
139+
assert _type.graphene_type == type, (
140+
'Found different types with the same name in the schema: {}, {}.'
141+
).format(_type.graphene_type, type)
136142
return _type
137143

138144
def interfaces():
@@ -155,7 +161,9 @@ def construct_interface(self, map, type):
155161
if type._meta.name in map:
156162
_type = map[type._meta.name]
157163
if isinstance(_type, GrapheneInterfaceType):
158-
assert _type.graphene_type == type
164+
assert _type.graphene_type == type, (
165+
'Found different types with the same name in the schema: {}, {}.'
166+
).format(_type.graphene_type, type)
159167
return _type
160168

161169
_resolve_type = None

0 commit comments

Comments
 (0)