Skip to content

Commit

Permalink
Fix missing AttributeError (#6536)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Jan 20, 2022
1 parent 6681a46 commit 21aff1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def get_dict(app: Any, key: str) -> Any:
def set_dict(app: Any, key: str, value: Any) -> None:
app.__app_dict[key] = value

app = mock.MagicMock()
app = mock.MagicMock(spec=Application)
app.__app_dict = {}
app.__getitem__ = get_dict
app.__setitem__ = set_dict
Expand Down
6 changes: 6 additions & 0 deletions tests/test_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ def test_make_mocked_request_app_can_store_values() -> None:
assert req.app["a_field"] == "a_value"


def test_make_mocked_request_app_access_non_existing() -> None:
req = make_mocked_request("GET", "/")
with pytest.raises(AttributeError):
req.app.foo


def test_make_mocked_request_match_info() -> None:
req = make_mocked_request("GET", "/", match_info={"a": "1", "b": "2"})
assert req.match_info == {"a": "1", "b": "2"}
Expand Down

0 comments on commit 21aff1f

Please sign in to comment.