Skip to content

Commit 46457b8

Browse files
authored
Make pylance happy by adding missing assertions (#3933)
* Add missing data assertions * Add missing skip reason * Move assertings next to declarations
1 parent e540634 commit 46457b8

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

tests/http/test_mutation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ async def test_mutation(http_client: HttpClient):
1111
data = response.json["data"]
1212

1313
assert response.status_code == 200
14+
assert isinstance(data, dict)
1415
assert data["hello"] == "strawberry"

tests/http/test_query.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ async def test_graphql_query(method: Literal["get", "post"], http_client: HttpCl
2020
method=method,
2121
query="{ hello }",
2222
)
23-
data = response.json["data"]
24-
2523
assert response.status_code == 200
24+
25+
data = response.json["data"]
26+
assert isinstance(data, dict)
2627
assert data["hello"] == "Hello world"
2728

2829

@@ -81,9 +82,10 @@ async def test_graphql_can_pass_variables(
8182
query="query hello($name: String!) { hello(name: $name) }",
8283
variables={"name": "Jake"},
8384
)
84-
data = response.json["data"]
85-
8685
assert response.status_code == 200
86+
87+
data = response.json["data"]
88+
assert isinstance(data, dict)
8789
assert data["hello"] == "Hello Jake"
8890

8991

@@ -135,9 +137,10 @@ async def test_root_value(method: Literal["get", "post"], http_client: HttpClien
135137
method=method,
136138
query="{ rootName }",
137139
)
138-
data = response.json["data"]
139-
140140
assert response.status_code == 200
141+
142+
data = response.json["data"]
143+
assert isinstance(data, dict)
141144
assert data["rootName"] == "Query"
142145

143146

@@ -268,13 +271,14 @@ async def test_query_context(method: Literal["get", "post"], http_client: HttpCl
268271
method=method,
269272
query="{ valueFromContext }",
270273
)
271-
data = response.json["data"]
272-
273274
assert response.status_code == 200
275+
276+
data = response.json["data"]
277+
assert isinstance(data, dict)
274278
assert data["valueFromContext"] == "a value from context"
275279

276280

277-
@skip_if_gql_32
281+
@skip_if_gql_32("formatting is different in gql 3.2")
278282
@pytest.mark.parametrize("method", ["get", "post"])
279283
async def test_query_extensions(
280284
method: Literal["get", "post"], http_client: HttpClient
@@ -284,9 +288,10 @@ async def test_query_extensions(
284288
query='{ valueFromExtensions(key:"test") }',
285289
extensions={"test": "hello"},
286290
)
287-
data = response.json["data"]
288-
289291
assert response.status_code == 200
292+
293+
data = response.json["data"]
294+
assert isinstance(data, dict)
290295
assert data["valueFromExtensions"] == "hello"
291296

292297

tests/http/test_upload.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def test_file_list_upload(enabled_http_client: HttpClient):
8080
)
8181

8282
data = response.json["data"]
83-
83+
assert isinstance(data, dict)
8484
assert len(data["readFiles"]) == 2
8585
assert data["readFiles"][0] == "strawberry1"
8686
assert data["readFiles"][1] == "strawberry2"
@@ -98,6 +98,7 @@ async def test_nested_file_list(enabled_http_client: HttpClient):
9898
)
9999

100100
data = response.json["data"]
101+
assert isinstance(data, dict)
101102
assert len(data["readFolder"]) == 2
102103
assert data["readFolder"][0] == "strawberry1"
103104
assert data["readFolder"][1] == "strawberry2"
@@ -121,6 +122,7 @@ async def test_upload_single_and_list_file_together(enabled_http_client: HttpCli
121122
)
122123

123124
data = response.json["data"]
125+
assert isinstance(data, dict)
124126
assert len(data["readFiles"]) == 2
125127
assert data["readFiles"][0] == "strawberry1"
126128
assert data["readFiles"][1] == "strawberry2"

0 commit comments

Comments
 (0)