Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add missing type hints for tests.unittest. #13397

Merged
merged 11 commits into from
Jul 27, 2022
4 changes: 1 addition & 3 deletions tests/rest/client/test_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,8 @@ def test_get_state_cancellation(self) -> None:
)

self.assertEqual(HTTPStatus.OK, channel.code, msg=channel.result["body"])
# json_body is defined as JsonDict, but it can be any valid JSON.
json_body: List[JsonDict] = channel.json_body # type: ignore[assignment]
self.assertCountEqual(
[state_event["type"] for state_event in json_body],
[state_event["type"] for state_event in channel.json_list],
{
"m.room.create",
"m.room.power_levels",
Expand Down
11 changes: 10 additions & 1 deletion tests/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Callable,
Dict,
Iterable,
List,
MutableMapping,
Optional,
Tuple,
Expand Down Expand Up @@ -121,7 +122,15 @@ def request(self, request: Request) -> None:

@property
def json_body(self) -> JsonDict:
return json.loads(self.text_body)
body = json.loads(self.text_body)
assert isinstance(body, dict)
return body

@property
def json_list(self) -> List[JsonDict]:
DMRobertson marked this conversation as resolved.
Show resolved Hide resolved
body = json.loads(self.text_body)
assert isinstance(body, list)
return body

@property
def text_body(self) -> str:
Expand Down