Skip to content

Commit 07f53bb

Browse files
committed
Fixed subscription tests in Py2
1 parent 8d51693 commit 07f53bb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

graphql/execution/tests/test_subscribe.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,20 @@
4444
)
4545

4646

47+
def get_unbound_function(func):
48+
if not getattr(func, '__self__', True):
49+
return func.__func__
50+
return func
51+
52+
4753
def email_schema_with_resolvers(resolve_fn=None):
4854
def default_resolver(root, info):
49-
return getattr(root, 'importantEmail', Observable.empty)()
55+
func = getattr(root, 'importantEmail', None)
56+
if func:
57+
func = get_unbound_function(func)
58+
return func()
59+
return Observable.empty()
60+
5061
return GraphQLSchema(
5162
query=QueryType,
5263
subscription=GraphQLObjectType(
@@ -76,8 +87,8 @@ def on_completed(self):
7687

7788

7889
def create_subscription(stream, schema=email_schema, ast=None, vars=None):
79-
class Root:
80-
class inbox:
90+
class Root(object):
91+
class inbox(object):
8192
emails = [
8293
Email(
8394

0 commit comments

Comments
 (0)