Skip to content

Fix tests with graphql-core 3.1.5 #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions tests/starwars/test_dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,15 @@ def test_multiple_operations(ds):
),
)

"""
From graphql-core version 3.1.5, print_ast() break arguments over multiple lines
Accepting both cases here
"""

assert (
print_ast(query)
== """query GetHeroName {
(
print_ast(query)
== """query GetHeroName {
hero {
name
}
Expand All @@ -280,6 +286,26 @@ def test_multiple_operations(ds):
}
}
"""
)
or (
print_ast(query)
== """query GetHeroName {
hero {
name
}
}

mutation CreateReviewMutation {
createReview(
episode: JEDI
review: {stars: 5, commentary: "This is a great movie!"}
) {
stars
commentary
}
}
"""
)
)


Expand Down
18 changes: 16 additions & 2 deletions tests/starwars/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,23 @@ def validation_errors(client, query):


def test_incompatible_request_gql(client):
with pytest.raises(TypeError) as exc_info:
with pytest.raises(TypeError):
gql(123)
assert "body must be a string" in str(exc_info.value)

"""
The error generated depends on graphql-core version
< 3.1.5: "body must be a string"
>= 3.1.5: some variation of "object of type 'int' has no len()"
depending on the python environment

So we are not going to check the exact error message here anymore.
"""

"""
assert ("body must be a string" in str(exc_info.value)) or (
"object of type 'int' has no len()" in str(exc_info.value)
)
"""


def test_nested_query_with_fragment(client):
Expand Down