From 349cc73763e66f48dff3be7e87b4a9f354911664 Mon Sep 17 00:00:00 2001 From: Vlad Stefan Munteanu Date: Mon, 29 Jun 2020 14:35:40 +0300 Subject: [PATCH] Fix hanging graphql tests (#989) * Use pytest-asyncio event loop when creating AsyncioExecutor in tests * Reformatting line width --- tests/test_graphql.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_graphql.py b/tests/test_graphql.py index 25f4a5ba..b50ac5a8 100644 --- a/tests/test_graphql.py +++ b/tests/test_graphql.py @@ -1,4 +1,5 @@ import graphene +import pytest from graphql.execution.executors.asyncio import AsyncioExecutor from starlette.applications import Starlette @@ -149,10 +150,17 @@ def test_graphql_async(): async_schema = graphene.Schema(query=ASyncQuery) -old_style_async_app = GraphQLApp(schema=async_schema, executor=AsyncioExecutor()) -def test_graphql_async_old_style_executor(): +@pytest.fixture +def old_style_async_app(event_loop) -> GraphQLApp: + old_style_async_app = GraphQLApp( + schema=async_schema, executor=AsyncioExecutor(loop=event_loop), + ) + return old_style_async_app + + +def test_graphql_async_old_style_executor(old_style_async_app: GraphQLApp): # See https://github.com/encode/starlette/issues/242 client = TestClient(old_style_async_app) response = client.get("/?query={ hello }")