Skip to content

Commit a5781ce

Browse files
committed
Avoid async warnings when running tests
1 parent 9fb4703 commit a5781ce

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

tests/execution/test_sync.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,18 @@ def does_not_return_a_promise_for_sync_execution():
102102
None,
103103
)
104104

105-
def throws_if_encountering_async_operation_with_check_sync():
105+
@mark.asyncio
106+
@mark.filterwarnings("ignore:.* was never awaited:RuntimeWarning")
107+
async def throws_if_encountering_async_operation_with_check_sync():
106108
doc = "query Example { syncField, asyncField }"
107109
with raises(RuntimeError) as exc_info:
108110
graphql_sync(schema, doc, "rootValue", check_sync=True)
109111
msg = str(exc_info.value)
110112
assert msg == "GraphQL execution failed to complete synchronously."
111113

114+
@mark.asyncio
112115
@mark.filterwarnings("ignore:.* was never awaited:RuntimeWarning")
113-
def throws_if_encountering_async_operation_without_check_sync():
116+
async def throws_if_encountering_async_operation_without_check_sync():
114117
doc = "query Example { syncField, asyncField }"
115118
result = graphql_sync(schema, doc, "rootValue")
116119
assert result == (
@@ -124,6 +127,6 @@ def throws_if_encountering_async_operation_without_check_sync():
124127
}
125128
],
126129
)
127-
# garbage collect coroutine in order to swallow warning
130+
# garbage collect coroutine in order to not postpone the warning
128131
del result
129132
collect()

tests/subscription/test_subscribe.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ async def should_pass_through_unexpected_errors_thrown_in_subscribe():
361361
await subscribe(schema=email_schema, document={}) # type: ignore
362362

363363
@mark.asyncio
364+
@mark.filterwarnings("ignore:.* was never awaited:RuntimeWarning")
364365
async def throws_an_error_if_subscribe_does_not_return_an_iterator():
365366
invalid_email_schema = GraphQLSchema(
366367
query=QueryType,

0 commit comments

Comments
 (0)