-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
Long story short
App is, among other things, a container for objects with an application-wide use. The default right now is to populate the app in the Request returned by make_mocked_request with unittest.mock.Mock, which doesn't support indexing, thus crashing when values in the app are accessed, unless MagicMock (or a dictionary) is explicitly put as app in the the call to make_mocked_request. I think the default should be to create the app as a MagicMock.
I couldn't test if that would brake any tests, because running tox was just spewing missing .h file errors at me and wouldn't run anything.
Expected behaviour
>>> from aiohttp.test_utils import make_mocked_request
>>> r = make_mocked_request('GET', '/bla')
>>> r.app['some_value']
<MagicMock name='mock.__getitem__()' id='139715764977336'>Actual behaviour
>>> from aiohttp.test_utils import make_mocked_request
>>> r = make_mocked_request('GET', '/bla')
>>> r.app['some_value']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'Mock' object does not support item assignment
'Mock' object does not support item assignmentYour environment
Aiohttp server: 3.3.2
OS: Kubuntu 17.10 x64
Reactions are currently unavailable