Skip to content

Fix tests with pytest-asyncio >= 1.0.0 #205

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

Merged
merged 3 commits into from
Jun 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ grpclib =
[tool:pytest]
addopts = -q --tb=native
testpaths = tests
asyncio_mode = auto
asyncio_mode = strict
filterwarnings =
error
ignore:.*pkg_resources.*:DeprecationWarning
Expand Down
9 changes: 6 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import asyncio

import pytest
import pytest_asyncio

from grpclib.config import Configuration


@pytest.fixture(name='loop')
def loop_fixture(event_loop):
@pytest_asyncio.fixture(name='loop')
async def loop_fixture():
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest-asyncio in strict mode (by default) requires to use pytest_asyncio.fixture decorator for async fixtures. I would try to switch to strict mode, to do so you need to remove asyncio_mode = auto line from setup.cfg file. I tried this and looks like your PR works and there are no other fixes required. Would you mind to update your PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done now. I wasn't sure if you're asking me to enable strict mode immediately, or just prepare it, so I did that as a separate commit — feel free to discard it if that's not what you wanted.

""" Shortcut """
return event_loop
return asyncio.get_running_loop()


@pytest.fixture(name='config')
Expand Down