-
Notifications
You must be signed in to change notification settings - Fork 801
Switch to pytest-asyncio's strict mode for async tests #1782
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
Switch to pytest-asyncio's strict mode for async tests #1782
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I think syncio
is just too close to asyncio
(to the point where my phone autocorrects it back to asyncio). I would be OK with sync
or any other word with a Levenshtein distance >= 2 from asyncio
.
(I would also be OK with a sed solution until unasync learns to deal with multi-token deletion rules.)
A Good point on the name, I'll change it. |
8002506
to
08036c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM.
@@ -70,6 +70,7 @@ def main(check=False): | |||
"async_pull_request": "pull_request", | |||
"async_examples": "examples", | |||
"assert_awaited_once_with": "assert_called_once_with", | |||
"pytest_asyncio": "pytest", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed now? Also, I think @pytest_asyncio.fixture
and @pytest.fixture
are probably clearer than @fixture
, but that can be addressed further down the road.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because pytest-asyncio's auto mode also takes care of reconfiguring any async fixtures declared with @pytest.fixture
appropriately. In strict mode you have to use @pytest_asyncio.fixture
instead.
I agree that @pytest.fixture
is better than @fixture
here, I'll change it.
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-8.x 8.x
# Navigate to the new working tree
cd .worktrees/backport-8.x
# Create a new branch
git switch --create backport-1782-to-8.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 81181ca8859f6ef8683ee1b323288bb52605f25a
# Push it to GitHub
git push --set-upstream origin backport-1782-to-8.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-8.x Then, create a pull request where the |
* Switch to pytest-asyncio's strict mode for async tests * add one missing test * use 'sync' as sync I/O marker (cherry picked from commit 81181ca)
* Switch to pytest-asyncio's strict mode for async tests * add one missing test * use 'sync' as sync I/O marker (cherry picked from commit 81181ca)
The trick is to using the following for async tests:
which is convert to the following for the unasynced tests:
This eliminates issues with unused imports, which would need to be taken care of in some, but not all files. WDYT?