From c09a5329ef15955d5108b6ff011a797c26747e3e Mon Sep 17 00:00:00 2001 From: Vlad Stefan Munteanu Date: Sun, 28 Jun 2020 12:38:45 +0300 Subject: [PATCH 1/2] Use pytest-asyncio event loop when creating AsyncioExecutor in tests --- tests/test_graphql.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_graphql.py b/tests/test_graphql.py index 25f4a5bae..bb64dc3ed 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,15 @@ 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 }") From d3abd99b23987d4d8f52140cab0a03ad265f78bc Mon Sep 17 00:00:00 2001 From: Vlad Stefan Munteanu Date: Sun, 28 Jun 2020 12:45:34 +0300 Subject: [PATCH 2/2] Reformatting line width --- tests/test_graphql.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_graphql.py b/tests/test_graphql.py index bb64dc3ed..b50ac5a87 100644 --- a/tests/test_graphql.py +++ b/tests/test_graphql.py @@ -154,7 +154,9 @@ def test_graphql_async(): @pytest.fixture def old_style_async_app(event_loop) -> GraphQLApp: - old_style_async_app = GraphQLApp(schema=async_schema, executor=AsyncioExecutor(loop=event_loop)) + old_style_async_app = GraphQLApp( + schema=async_schema, executor=AsyncioExecutor(loop=event_loop), + ) return old_style_async_app