Skip to content

Commit beab41b

Browse files
authored
Fix tests with graphql-core 3.1.5 (#211)
* Fix tests to allow graphql-core>=3.1.5 to break arguments over multiple lines * Stop checking exact error message when passing an int to gql
1 parent 73d0ba5 commit beab41b

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

tests/starwars/test_dsl.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,15 @@ def test_multiple_operations(ds):
264264
),
265265
)
266266

267+
"""
268+
From graphql-core version 3.1.5, print_ast() break arguments over multiple lines
269+
Accepting both cases here
270+
"""
271+
267272
assert (
268-
print_ast(query)
269-
== """query GetHeroName {
273+
(
274+
print_ast(query)
275+
== """query GetHeroName {
270276
hero {
271277
name
272278
}
@@ -280,6 +286,26 @@ def test_multiple_operations(ds):
280286
}
281287
}
282288
"""
289+
)
290+
or (
291+
print_ast(query)
292+
== """query GetHeroName {
293+
hero {
294+
name
295+
}
296+
}
297+
298+
mutation CreateReviewMutation {
299+
createReview(
300+
episode: JEDI
301+
review: {stars: 5, commentary: "This is a great movie!"}
302+
) {
303+
stars
304+
commentary
305+
}
306+
}
307+
"""
308+
)
283309
)
284310

285311

tests/starwars/test_validation.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,23 @@ def validation_errors(client, query):
7575

7676

7777
def test_incompatible_request_gql(client):
78-
with pytest.raises(TypeError) as exc_info:
78+
with pytest.raises(TypeError):
7979
gql(123)
80-
assert "body must be a string" in str(exc_info.value)
80+
81+
"""
82+
The error generated depends on graphql-core version
83+
< 3.1.5: "body must be a string"
84+
>= 3.1.5: some variation of "object of type 'int' has no len()"
85+
depending on the python environment
86+
87+
So we are not going to check the exact error message here anymore.
88+
"""
89+
90+
"""
91+
assert ("body must be a string" in str(exc_info.value)) or (
92+
"object of type 'int' has no len()" in str(exc_info.value)
93+
)
94+
"""
8195

8296

8397
def test_nested_query_with_fragment(client):

0 commit comments

Comments
 (0)