diff --git a/aiohttp/test_utils.py b/aiohttp/test_utils.py index fdc63ee9c4d..daa8527e11d 100644 --- a/aiohttp/test_utils.py +++ b/aiohttp/test_utils.py @@ -448,7 +448,7 @@ def teardown_test_loop(loop, fast=False): def _create_app_mock(): - app = mock.Mock() + app = mock.MagicMock() app._debug = False app.on_response_prepare = Signal(app) app.on_response_prepare.freeze() diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index a45e7cab753..92d4d7a978c 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -189,6 +189,11 @@ def test_make_mocked_request_app(): assert req.app is app +def test_make_mocked_request_app_doesnt_crash_on_key_access(): + req = make_mocked_request('GET', '/') + req.app["accessing this shouldn't crash"] + + def test_make_mocked_request_match_info(): req = make_mocked_request('GET', '/', match_info={'a': '1', 'b': '2'}) assert req.match_info == {'a': '1', 'b': '2'}