Skip to content

Commit d213449

Browse files
committed
test: restore full coverage for aborted resolver tests
The with_abort_signal helper added for the #4267 port cancels a pre-aborted async resolver before its body runs; because GraphQL-Core coroutines are lazy (unlike the eager resolvers in graphql-js, whose bodies execute before the wrapped promise rejects), the resolver bodies in the abort-before-await cancellation tests became unreachable and dropped coverage below 100%. Mark them no-cover, mirroring the c8-ignore graphql-js puts on the analogous never-called callbacks.
1 parent d3ab169 commit d213449

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

tests/execution/test_abort_signal.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ async def stops_the_execution_when_aborted_during_object_field_completion():
100100
)
101101

102102
async def todo(_info):
103-
return {
103+
# never reached: a triggered abort signal cancels this resolver
104+
# before its body runs (unlike the eager resolvers in graphql-js)
105+
return { # pragma: no cover
104106
"id": "1",
105107
"author": must_not_be_called,
106108
}
@@ -143,7 +145,8 @@ async def provides_access_to_the_abort_signal_within_resolvers():
143145
)
144146

145147
async def cancellable_async_fn(abort_signal):
146-
raise await abort_signal.wait()
148+
# never reached: the resolver is cancelled before its body runs
149+
raise await abort_signal.wait() # pragma: no cover
147150

148151
# Contrary to JavaScript, where the abort signal is passed as an additional
149152
# argument to the resolvers, in GraphQL-Core it is available via the resolve
@@ -192,7 +195,9 @@ async def stops_the_execution_when_aborted_during_completion_with_custom_error()
192195
)
193196

194197
async def todo(_info):
195-
return {
198+
# never reached: a triggered abort signal cancels this resolver
199+
# before its body runs (unlike the eager resolvers in graphql-js)
200+
return { # pragma: no cover
196201
"id": "1",
197202
"author": must_not_be_called,
198203
}
@@ -239,7 +244,9 @@ async def stops_the_execution_when_aborted_during_completion_with_custom_string(
239244
)
240245

241246
async def todo(_info):
242-
return {
247+
# never reached: a triggered abort signal cancels this resolver
248+
# before its body runs (unlike the eager resolvers in graphql-js)
249+
return { # pragma: no cover
243250
"id": "1",
244251
"author": must_not_be_called,
245252
}
@@ -283,7 +290,8 @@ async def stops_the_execution_when_aborted_during_nested_object_completion():
283290
)
284291

285292
async def author(_info):
286-
return must_not_be_called
293+
# never reached: the resolver is cancelled before its body runs
294+
return must_not_be_called # pragma: no cover
287295

288296
awaitable_result = execute(
289297
schema,
@@ -423,7 +431,9 @@ async def stops_the_execution_when_aborted_with_proper_null_bubbling():
423431
)
424432

425433
async def non_nullable_todo(_info):
426-
return {
434+
# never reached: a triggered abort signal cancels this resolver
435+
# before its body runs (unlike the eager resolvers in graphql-js)
436+
return { # pragma: no cover
427437
"id": "1",
428438
"author": must_not_be_called,
429439
}

0 commit comments

Comments
 (0)