Skip to content

Commit 7f6fa16

Browse files
feat_ (#1476)
Previously, installing graphene and trying to do `from graphene.test import Client` as recommended in the docs caused an `ImportError`, as the 'promise' library is imported but only listed as a requirement in the 'test' section of the setup.py file.
1 parent 0b1bfbf commit 7f6fa16

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

graphene/relay/tests/test_mutation_async.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from graphene.types import ID, Field, ObjectType, Schema
44
from graphene.types.scalars import String
55
from graphene.relay.mutation import ClientIDMutation
6+
from graphene.test import Client
67

78

89
class SharedFields(object):
@@ -61,24 +62,27 @@ class Mutation(ObjectType):
6162

6263

6364
schema = Schema(query=RootQuery, mutation=Mutation)
65+
client = Client(schema)
6466

6567

6668
@mark.asyncio
6769
async def test_node_query_promise():
68-
executed = await schema.execute_async(
70+
executed = await client.execute_async(
6971
'mutation a { sayPromise(input: {what:"hello", clientMutationId:"1"}) { phrase } }'
7072
)
71-
assert not executed.errors
72-
assert executed.data == {"sayPromise": {"phrase": "hello"}}
73+
assert isinstance(executed, dict)
74+
assert "errors" not in executed
75+
assert executed["data"] == {"sayPromise": {"phrase": "hello"}}
7376

7477

7578
@mark.asyncio
7679
async def test_edge_query():
77-
executed = await schema.execute_async(
80+
executed = await client.execute_async(
7881
'mutation a { other(input: {clientMutationId:"1"}) { clientMutationId, myNodeEdge { cursor node { name }} } }'
7982
)
80-
assert not executed.errors
81-
assert dict(executed.data) == {
83+
assert isinstance(executed, dict)
84+
assert "errors" not in executed
85+
assert executed["data"] == {
8286
"other": {
8387
"clientMutationId": "1",
8488
"myNodeEdge": {"cursor": "1", "node": {"name": "name"}},

graphene/test/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from promise import Promise, is_thenable
21
from graphql.error import GraphQLError
32

43
from graphene.types.schema import Schema
@@ -31,7 +30,10 @@ def format_result(self, result):
3130

3231
def execute(self, *args, **kwargs):
3332
executed = self.schema.execute(*args, **dict(self.execute_options, **kwargs))
34-
if is_thenable(executed):
35-
return Promise.resolve(executed).then(self.format_result)
33+
return self.format_result(executed)
3634

35+
async def execute_async(self, *args, **kwargs):
36+
executed = await self.schema.execute_async(
37+
*args, **dict(self.execute_options, **kwargs)
38+
)
3739
return self.format_result(executed)

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def run_tests(self):
5252
"pytest-asyncio>=0.16,<2",
5353
"snapshottest>=0.6,<1",
5454
"coveralls>=3.3,<4",
55-
"promise>=2.3,<3",
5655
"mock>=4,<5",
5756
"pytz==2022.1",
5857
"iso8601>=1,<2",

0 commit comments

Comments
 (0)