Skip to content

Commit 895b324

Browse files
committed
Improved promise async integration. Fixed #67
1 parent f31e7d9 commit 895b324

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ before_install:
2222
source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate"
2323
fi
2424
install:
25-
- pip install --cache-dir $HOME/.cache/pip pytest-cov pytest-mock coveralls flake8 isort==3.9.6 gevent==1.1b5 six>=1.10.0 promise>=0.4.0
25+
- pip install --cache-dir $HOME/.cache/pip pytest-cov pytest-mock coveralls flake8 isort==3.9.6 gevent==1.1b5 six>=1.10.0 promise>=0.4.2
2626
- pip install --cache-dir $HOME/.cache/pip pytest>=2.7.3 --upgrade
2727
- pip install -e .
2828
script:

graphql/execution/tests/test_executor_asyncio.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
isort:skip_file
33
"""
44
# flake8: noqa
5+
56
import pytest
67
asyncio = pytest.importorskip("asyncio")
78

graphql/execution/tests/test_executor_gevent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
isort:skip_file
33
"""
44
# flake8: noqa
5+
56
import pytest
67
gevent = pytest.importorskip("gevent")
78

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
packages=find_packages(exclude=['tests', 'tests_py35']),
4646
install_requires=[
4747
'six>=1.10.0',
48-
'promise>=0.4.0'
48+
'promise>=0.4.2'
4949
],
5050
tests_require=[
5151
'pytest>=2.7.3',

tests_py35/core_execution/test_asyncio_executor.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# flake8: noqa
2-
2+
import pytest
33
import asyncio
44
import functools
55
from graphql.error import format_error
@@ -39,8 +39,7 @@ def resolver_3(context, *_):
3939
assert result.data == {'a': 'hey', 'b': 'hey2', 'c': 'hey3'}
4040

4141

42-
@pytest.mark.asyncio
43-
async def test_asyncio_py35_executor_return_promise(event_loop):
42+
def test_asyncio_py35_executor_return_promise():
4443
ast = parse('query Example { a, b, c }')
4544

4645
async def resolver(context, *_):
@@ -60,9 +59,14 @@ def resolver_3(context, *_):
6059
'c': GraphQLField(GraphQLString, resolver=resolver_3)
6160
})
6261

63-
result = await execute(GraphQLSchema(Type), ast, executor=AsyncioExecutor(loop=event_loop), return_promise=True)
64-
assert not result.errors
65-
assert result.data == {'a': 'hey', 'b': 'hey2', 'c': 'hey3'}
62+
loop = asyncio.get_event_loop()
63+
64+
async def do_exec():
65+
result = await execute(GraphQLSchema(Type), ast, executor=AsyncioExecutor(loop), return_promise=True)
66+
assert not result.errors
67+
assert result.data == {'a': 'hey', 'b': 'hey2', 'c': 'hey3'}
68+
69+
loop.run_until_complete(do_exec())
6670

6771

6872
def test_asyncio_py35_executor_with_error():

0 commit comments

Comments
 (0)