Fix hanging graphql tests (#989)

* Use pytest-asyncio event loop when creating AsyncioExecutor in tests

* Reformatting line width
This commit is contained in:
Vlad Stefan Munteanu 2020-06-29 14:35:40 +03:00 committed by GitHub
parent 4e2f301426
commit 349cc73763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -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 }")