Skip to content

Commit 8bda661

Browse files
committed
coverage: mark ignore statements
Replicates graphql/graphql-js@6efefae
1 parent d52c0a8 commit 8bda661

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

src/graphql/type/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def is_possible_type(
260260
261261
Deprecated: Use is_sub_type() instead.
262262
"""
263-
return self.is_sub_type(abstract_type, possible_type)
263+
return self.is_sub_type(abstract_type, possible_type) # pragma: no cover
264264

265265
def is_sub_type(
266266
self,
@@ -341,7 +341,7 @@ def type_map_directive_reducer(
341341
"""Reducer function for creating the type map from given directives."""
342342
# Directives are not validated until validate_schema() is called.
343343
if not is_directive(directive):
344-
return map_
344+
return map_ # pragma: no cover
345345
directive = cast(GraphQLDirective, directive)
346346
return reduce(
347347
lambda prev_map, arg: self.type_map_reducer(

tests/error/test_graphql_error.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ def uses_the_stack_of_an_original_error():
5252
assert e.original_error is original
5353
assert str(e.original_error) == "original"
5454

55+
def passes_the_context_of_an_original_error():
56+
context = ValueError("cause")
57+
try:
58+
raise context
59+
except ValueError:
60+
try:
61+
raise RuntimeError("effect")
62+
except RuntimeError as runtime_error:
63+
original = runtime_error
64+
e = GraphQLError("msg", original_error=original)
65+
assert e.__context__ is context
66+
67+
def passes_the_cause_of_an_original_error():
68+
cause = ValueError("cause")
69+
try:
70+
raise RuntimeError("effect") from cause
71+
except RuntimeError as runtime_error:
72+
original = runtime_error
73+
e = GraphQLError("msg", original_error=original)
74+
assert e.__cause__ is cause
75+
5576
def creates_new_stack_if_original_error_has_no_stack():
5677
try:
5778
raise RuntimeError
@@ -108,12 +129,22 @@ def serializes_to_include_message_and_locations():
108129
"GraphQLError('msg', locations=[SourceLocation(line=2, column=3)])"
109130
)
110131

132+
def repr_includes_extensions():
133+
e = GraphQLError("msg", extensions={"foo": "bar"})
134+
assert repr(e) == ("GraphQLError('msg', extensions={'foo': 'bar'})")
135+
111136
def serializes_to_include_path():
112137
path: List[Union[int, str]] = ["path", 3, "to", "field"]
113138
e = GraphQLError("msg", path=path)
114139
assert e.path is path
115140
assert repr(e) == "GraphQLError('msg', path=['path', 3, 'to', 'field'])"
116141

142+
def always_stores_path_as_list():
143+
path: List[Union[int, str]] = ["path", 3, "to", "field"]
144+
e = GraphQLError("msg,", path=tuple(path))
145+
assert isinstance(e.path, list)
146+
assert e.path == path
147+
117148
def is_hashable():
118149
hash(GraphQLError("msg"))
119150

0 commit comments

Comments
 (0)