1+ import pytest
12from promise import Promise
23from promise .dataloader import DataLoader
34
45from graphql import GraphQLObjectType , GraphQLField , GraphQLID , GraphQLArgument , GraphQLNonNull , GraphQLSchema , parse , execute
6+ from graphql .execution .executors .sync import SyncExecutor
7+ from graphql .execution .executors .thread import ThreadExecutor
58
69
7- def test_batches_correctly ():
10+ @pytest .mark .parametrize ("executor" , [
11+ SyncExecutor (),
12+ ThreadExecutor (),
13+ ])
14+ def test_batches_correctly (executor ):
815
916 Business = GraphQLObjectType ('Business' , lambda : {
1017 'id' : GraphQLField (GraphQLID , resolver = lambda root , args , context , info : root ),
@@ -46,7 +53,7 @@ class Context(object):
4653 business_data_loader = BusinessDataLoader ()
4754
4855
49- result = execute (schema , doc_ast , None , context_value = Context ())
56+ result = execute (schema , doc_ast , None , context_value = Context (), executor = executor )
5057 assert not result .errors
5158 assert result .data == {
5259 'business1' : {
@@ -59,7 +66,11 @@ class Context(object):
5966 assert load_calls == [['1' ,'2' ]]
6067
6168
62- def test_batches_multiple_together ():
69+ @pytest .mark .parametrize ("executor" , [
70+ SyncExecutor (),
71+ ThreadExecutor (),
72+ ])
73+ def test_batches_multiple_together (executor ):
6374
6475 Location = GraphQLObjectType ('Location' , lambda : {
6576 'id' : GraphQLField (GraphQLID , resolver = lambda root , args , context , info : root ),
@@ -122,7 +133,7 @@ class Context(object):
122133 location_data_loader = LocationDataLoader ()
123134
124135
125- result = execute (schema , doc_ast , None , context_value = Context ())
136+ result = execute (schema , doc_ast , None , context_value = Context (), executor = executor )
126137 assert not result .errors
127138 assert result .data == {
128139 'business1' : {
0 commit comments