1- # flake8: noqa
1+ import asyncio
22
3- import pytest
4-
5- asyncio = pytest .importorskip ("asyncio" )
3+ from promise import Promise
64
75from graphql .execution .executors .asyncio import AsyncioExecutor
86from graphql .type .definition import (
1311from graphql .type .scalars import GraphQLString
1412from graphql .type .schema import GraphQLSchema
1513from graphql_server import RequestParams , run_http_query
16- from promise import Promise
1714
1815from .utils import as_dicts
1916
@@ -22,19 +19,17 @@ def resolve_error_sync(_obj, _info):
2219 raise ValueError ("error sync" )
2320
2421
25- @asyncio .coroutine
26- def resolve_error_async (_obj , _info ):
27- yield from asyncio .sleep (0.001 )
22+ async def resolve_error_async (_obj , _info ):
23+ await asyncio .sleep (0.001 )
2824 raise ValueError ("error async" )
2925
3026
3127def resolve_field_sync (_obj , _info ):
3228 return "sync"
3329
3430
35- @asyncio .coroutine
36- def resolve_field_async (_obj , info ):
37- yield from asyncio .sleep (0.001 )
31+ async def resolve_field_async (_obj , info ):
32+ await asyncio .sleep (0.001 )
3833 return "async"
3934
4035
@@ -53,7 +48,7 @@ def resolve_field_async(_obj, info):
5348schema = GraphQLSchema (QueryRootType )
5449
5550
56- def test_get_reponses_using_asyncioexecutor ():
51+ def test_get_responses_using_asyncio_executor ():
5752 class TestExecutor (AsyncioExecutor ):
5853 called = False
5954 waited = False
@@ -75,8 +70,7 @@ def execute(self, fn, *args, **kwargs):
7570
7671 loop = asyncio .get_event_loop ()
7772
78- @asyncio .coroutine
79- def get_results ():
73+ async def get_results ():
8074 result_promises , params = run_http_query (
8175 schema ,
8276 "get" ,
@@ -85,7 +79,7 @@ def get_results():
8579 executor = TestExecutor (loop = loop ),
8680 return_promise = True ,
8781 )
88- results = yield from Promise .all (result_promises )
82+ results = await Promise .all (result_promises )
8983 return results , params
9084
9185 results , params = loop .run_until_complete (get_results ())
0 commit comments