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 #4020

Closed
rathann opened this issue Jun 3, 2020 · 4 comments
Closed

Migrate asynctest to stdlib's AsyncMock #4020

rathann opened this issue Jun 3, 2020 · 4 comments
Labels
kind/triage Unclassified issues

Comments

@rathann
Copy link
Contributor

rathann commented Jun 3, 2020

Problem Description

test/mitmproxy/addons/test_readfile.py:5 imports asynctest which 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 asynctest/issues/144 and asynctest/issues/126 .

Fortunately, this is the only test that seems to be affected.

@rathann rathann added the kind/triage Unclassified issues label Jun 3, 2020
@Kriechi
Copy link
Member

Kriechi commented Jun 7, 2020

We do have a green CI test on Python 3.8:
https://github.com/mitmproxy/mitmproxy/runs/724843736?check_suite_focus=true

How is the test failing for you?

@mhils mhils changed the title test/mitmproxy/addons/test_readfile.py depends on deprecated asynctest (broken in python 3.8+) Migrate asynctest to stdlib's AsyncMock Jun 11, 2020
@mhils
Copy link
Member

mhils commented Jun 11, 2020

We probably want to migrate to the stdlib implementation here, but that requires us to drop Python 3.7 and below. I'd be fine doing this, but we're blocked by PyInstaller which does not support 3.8 yet (pyinstaller/pyinstaller#4311).

@bnavigator
Copy link

You are using pytest-asyncio already. Replace the asynctest.patch calls with fixture from pytest-mock? pytest-dev/pytest-asyncio#42

@mhils
Copy link
Member

mhils commented Aug 11, 2020

@bnavigator: works for me as well. If you would like to send a PR, that would be fabulous! 😃

mhils pushed a commit that referenced this issue Nov 16, 2020
This is an implementation of
#4020

Tested to work fine here with Python 3.8.6.
@mhils mhils closed this as completed Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/triage Unclassified issues
Projects
None yet
Development

No branches or pull requests

4 participants