Skip to content

Commit e93ec8d

Browse files
committed
Adapt error message in test to change in wording
1 parent 0eb4325 commit e93ec8d

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

tests/starwars/test_query.py

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pytest
2-
from graphql import format_error
2+
from graphql import GraphQLError, format_error
33

44
from gql import Client, gql
55
from tests.starwars.schema import StarWarsSchema
@@ -18,7 +18,7 @@ def test_hero_name_query(client):
1818
name
1919
}
2020
}
21-
"""
21+
"""
2222
)
2323
expected = {"hero": {"name": "R2-D2"}}
2424
result = client.execute(query)
@@ -37,7 +37,7 @@ def test_hero_name_and_friends_query(client):
3737
}
3838
}
3939
}
40-
"""
40+
"""
4141
)
4242
expected = {
4343
"hero": {
@@ -69,7 +69,7 @@ def test_nested_query(client):
6969
}
7070
}
7171
}
72-
"""
72+
"""
7373
)
7474
expected = {
7575
"hero": {
@@ -119,7 +119,7 @@ def test_fetch_luke_query(client):
119119
name
120120
}
121121
}
122-
"""
122+
"""
123123
)
124124
expected = {"human": {"name": "Luke Skywalker"}}
125125
result = client.execute(query)
@@ -134,7 +134,7 @@ def test_fetch_some_id_query(client):
134134
name
135135
}
136136
}
137-
"""
137+
"""
138138
)
139139
params = {
140140
"someId": "1000",
@@ -152,7 +152,7 @@ def test_fetch_some_id_query2(client):
152152
name
153153
}
154154
}
155-
"""
155+
"""
156156
)
157157
params = {
158158
"someId": "1002",
@@ -170,7 +170,7 @@ def test_invalid_id_query(client):
170170
name
171171
}
172172
}
173-
"""
173+
"""
174174
)
175175
params = {
176176
"id": "not a valid id",
@@ -188,7 +188,7 @@ def test_fetch_luke_aliased(client):
188188
name
189189
}
190190
}
191-
"""
191+
"""
192192
)
193193
expected = {"luke": {"name": "Luke Skywalker"}}
194194
result = client.execute(query)
@@ -206,7 +206,7 @@ def test_fetch_luke_and_leia_aliased(client):
206206
name
207207
}
208208
}
209-
"""
209+
"""
210210
)
211211
expected = {"luke": {"name": "Luke Skywalker"}, "leia": {"name": "Leia Organa"}}
212212
result = client.execute(query)
@@ -226,7 +226,7 @@ def test_duplicate_fields(client):
226226
homePlanet
227227
}
228228
}
229-
"""
229+
"""
230230
)
231231
expected = {
232232
"luke": {"name": "Luke Skywalker", "homePlanet": "Tatooine"},
@@ -251,7 +251,7 @@ def test_use_fragment(client):
251251
name
252252
homePlanet
253253
}
254-
"""
254+
"""
255255
)
256256
expected = {
257257
"luke": {"name": "Luke Skywalker", "homePlanet": "Tatooine"},
@@ -270,7 +270,7 @@ def test_check_type_of_r2(client):
270270
name
271271
}
272272
}
273-
"""
273+
"""
274274
)
275275
expected = {"hero": {"__typename": "Droid", "name": "R2-D2"}}
276276
result = client.execute(query)
@@ -286,27 +286,25 @@ def test_check_type_of_luke(client):
286286
name
287287
}
288288
}
289-
"""
289+
"""
290290
)
291291
expected = {"hero": {"__typename": "Human", "name": "Luke Skywalker"}}
292292
result = client.execute(query)
293293
assert result == expected
294294

295295

296296
def test_parse_error(client):
297-
result = None
298297
with pytest.raises(Exception) as exc_info:
299-
query = gql(
298+
gql(
300299
"""
301300
qeury
302-
"""
301+
"""
303302
)
304-
result = client.execute(query)
305303
error = exc_info.value
304+
assert isinstance(error, GraphQLError)
306305
formatted_error = format_error(error)
307306
assert formatted_error["locations"] == [{"column": 13, "line": 2}]
308307
assert formatted_error["message"] == "Syntax Error: Unexpected Name 'qeury'."
309-
assert not result
310308

311309

312310
def test_mutation_result(client):
@@ -318,7 +316,7 @@ def test_mutation_result(client):
318316
commentary
319317
}
320318
}
321-
"""
319+
"""
322320
)
323321
params = {
324322
"ep": "JEDI",

tests/test_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_no_schema_exception():
7373
with pytest.raises(Exception) as exc_info:
7474
client = Client()
7575
client.validate("")
76-
assert "Cannot validate locally the document, you need to pass a schema." in str(
76+
assert "Cannot validate the document locally, you need to pass a schema." in str(
7777
exc_info.value
7878
)
7979

0 commit comments

Comments
 (0)