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

Migrate asynctest to stdlib's AsyncMock #475

Closed
fabaff opened this issue Sep 8, 2020 · 2 comments · Fixed by #489
Closed

Migrate asynctest to stdlib's AsyncMock #475

fabaff opened this issue Sep 8, 2020 · 2 comments · Fixed by #489

Comments

@fabaff
Copy link

fabaff commented Sep 8, 2020

Asynctest doesn't work with Python 3.8 and above.

Asynctest upstream is aware of this breakage and recommends using the built-in AsyncMock instead.

See also Martiusweb/asynctest#144 and Martiusweb/asynctest#126

@puddly
Copy link
Collaborator

puddly commented Sep 8, 2020

What's the recommended approach for mocking coroutines on Python 3.7? Is there any backport of AsyncMock other than the one in asynctest?

try:
    # Python 3.8 already has this
    from mock import AsyncMock as CoroutineMock
except ImportError:
    from asynctest import CoroutineMock

@Adminiuga
Copy link
Collaborator

we could take HA's core approach and just import CoroutineMock and/or mock from the local asyncmock module
https://github.com/home-assistant/core/blob/dev/tests/async_mock.py

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

Successfully merging a pull request may close this issue.

3 participants