Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MagicMock without doesn't mock __aenter__ and __aexit__ with a CoroutineMock #55

Closed
Martiusweb opened this issue Nov 2, 2017 · 1 comment
Assignees
Labels

Comments

@Martiusweb
Copy link
Owner

Currently, it is not possible to use MagicMock with asynchronous context managers without spec, because aenter, aexit aren't mocked with CoroutineMock by default.

>>> from asynctest import MagicMock
>>> from asyncio import get_event_loop
>>> 
>>> async def f():
...    async with MagicMock():
...        print('f()')
...
>>> get_event_loop().run_until_complete(f())
TypeError: object MagicMock can't be used in 'await' expression
@Martiusweb
Copy link
Owner Author

This is fixed by commit 9fdd897, which is part of the release 0.11.1 which should be released very soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant