Skip to content

Commit

Permalink
Fix hanging graphql tests (#989)
Browse files Browse the repository at this point in the history
* Use pytest-asyncio event loop when creating AsyncioExecutor in tests

* Reformatting line width
  • Loading branch information
vladmunteanu committed Jun 29, 2020
1 parent 4e2f301 commit 349cc73
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/test_graphql.py
@@ -1,4 +1,5 @@
import graphene
import pytest
from graphql.execution.executors.asyncio import AsyncioExecutor

from starlette.applications import Starlette
Expand Down Expand Up @@ -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 }")
Expand Down

0 comments on commit 349cc73

Please sign in to comment.