We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Here's a python test file that I'd expect to pass:
import pytest from collections.abc import AsyncGenerator @pytest.fixture() async def fixture() -> AsyncGenerator[str, None]: yield "a" @pytest.mark.asyncio async def test(fixture: str): assert fixture == "a"
However, it does not pass due to the error: AssertionError: assert <async_generator object fixture at 0x104723740> == 'a'
AssertionError: assert <async_generator object fixture at 0x104723740> == 'a'
I'm using:
pytest==8.2.1 pytest-asyncio==0.23.7
Repo to reproduce can be found here.
Full output of pytest -v test.py:
pytest -v test.py
============================================================================== test session starts ============================================================================== platform darwin -- Python 3.11.2, pytest-8.0.0, pluggy-1.4.0 -- /Users/REDACTED/.pyenv/versions/3.11.2/bin/python3.11 cachedir: .pytest_cache rootdir: /Users/REDACTED/workspace/pytest-asyncio-issue plugins: asyncio-0.23.5, xdist-3.5.0, anyio-3.6.2 asyncio: mode=Mode.STRICT collected 1 item test.py::test FAILED [100%] =================================================================================== FAILURES ==================================================================================== _____________________________________________________________________________________ test ______________________________________________________________________________________ fixture = <async_generator object fixture at 0x104723740> @pytest.mark.asyncio async def test(fixture: str): > assert fixture == "a" E AssertionError: assert <async_generator object fixture at 0x104723740> == 'a' test.py:10: AssertionError ============================================================================ short test summary info ============================================================================ FAILED test.py::test - AssertionError: assert <async_generator object fixture at 0x104723740> == 'a' =============================================================================== 1 failed in 0.07s ===============================================================================
The text was updated successfully, but these errors were encountered:
Ah, my bad. The correct code should use @pytest_asyncio.fixture rather than @pytest.fixture:
@pytest_asyncio.fixture
@pytest.fixture
import pytest import pytest_asyncio from collections.abc import AsyncGenerator @pytest_asyncio.fixture() async def fixture() -> AsyncGenerator[str, None]: yield "a" @pytest.mark.asyncio async def test(fixture: str): assert fixture == "a"
Sorry, something went wrong.
No branches or pull requests
Here's a python test file that I'd expect to pass:
However, it does not pass due to the error:
AssertionError: assert <async_generator object fixture at 0x104723740> == 'a'
I'm using:
Repo to reproduce can be found here.
Full output of
pytest -v test.py
:The text was updated successfully, but these errors were encountered: