Skip to content

Commit c1eaf2e

Browse files
committed
Fixed py35 tests
1 parent 759cf82 commit c1eaf2e

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

graphql/execution/executors/asyncio.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import
22

33
from asyncio import Future, get_event_loop, iscoroutine, wait
4+
from promise import promisify
45

56
try:
67
from asyncio import ensure_future
@@ -45,5 +46,5 @@ def execute(self, fn, *args, **kwargs):
4546
if isinstance(result, Future) or iscoroutine(result):
4647
future = ensure_future(result, loop=self.loop)
4748
self.futures.append(future)
48-
return future
49+
return promisify(future)
4950
return result

graphql/execution/tests/test_benchmark.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def test_big_list_of_ints(benchmark):
7-
big_int_list = [x for x in range(10000)]
7+
big_int_list = [x for x in range(5000)]
88

99
def resolve_all_ints(root, args, context, info):
1010
return big_int_list
@@ -25,6 +25,19 @@ def resolve_all_ints(root, args, context, info):
2525
assert result.data == {'allInts': big_int_list}
2626

2727

28+
29+
def test_big_list_of_ints(benchmark):
30+
big_int_list = [x for x in range(5000)]
31+
from ..executor import complete_leaf_value
32+
# def convert_item(i):
33+
# return i
34+
35+
def convert_list():
36+
r = []
37+
for i in big_int_list:
38+
r.append(GraphQLInt.serialize(i))
39+
return r
40+
benchmark(convert_list)
2841
def test_big_list_of_containers_with_one_field(benchmark):
2942
Container = namedtuple('Container', 'x y z o')
3043

@@ -35,7 +48,7 @@ def test_big_list_of_containers_with_one_field(benchmark):
3548
'o': GraphQLField(GraphQLInt),
3649
})
3750

38-
big_container_list = [Container(x=x, y=x, z=x, o=x) for x in range(10000)]
51+
big_container_list = [Container(x=x, y=x, z=x, o=x) for x in range(5000)]
3952

4053
def resolve_all_containers(root, args, context, info):
4154
return big_container_list
@@ -66,7 +79,7 @@ def test_big_list_of_containers_with_multiple_fields(benchmark):
6679
'o': GraphQLField(GraphQLInt),
6780
})
6881

69-
big_container_list = [Container(x=x, y=x, z=x, o=x) for x in range(10000)]
82+
big_container_list = [Container(x=x, y=x, z=x, o=x) for x in range(5000)]
7083

7184
def resolve_all_containers(root, args, context, info):
7285
return big_container_list

0 commit comments

Comments
 (0)