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

Error reproducing an example from the REAME.md #51

Closed
netsmash opened this issue Sep 19, 2022 · 3 comments
Closed

Error reproducing an example from the REAME.md #51

netsmash opened this issue Sep 19, 2022 · 3 comments

Comments

@netsmash
Copy link
Contributor

I reproduced the app example given in the README.txt and I got the following error:

❯ pytest -s test_app.py
========================================== test session starts ===========================================
platform linux -- Python 3.10.7, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/daniel/coding/python/test-asgi-lifespan
plugins: anyio-3.6.1, asyncio-0.19.0
asyncio: mode=strict
collected 1 item

test_app.py Testing
F

================================================ FAILURES ================================================
_______________________________________________ test_home ________________________________________________

client = <async_generator object client at 0x7f65b037a9c0>

    @pytest.mark.asyncio
    async def test_home(client):
        print("Testing")
>       response = await client.get("/")
E       AttributeError: 'async_generator' object has no attribute 'get'

test_app.py:43: AttributeError
======================================== short test summary info =========================================
FAILED test_app.py::test_home - AttributeError: 'async_generator' object has no attribute 'get'
=========================================== 1 failed in 0.06s ============================================

I run pytest -s test_app.py on a new environment with the installed packages explained in the README. Here is my pip list:

Package        Version
-------------- ---------
anyio          3.6.1
asgi-lifespan  1.0.1
attrs          22.1.0
certifi        2022.9.14
h11            0.12.0
httpcore       0.15.0
httpx          0.23.0
idna           3.4
iniconfig      1.1.1
packaging      21.3
pip            22.2.2
pluggy         1.0.0
py             1.11.0
pyparsing      3.0.9
pytest         7.1.3
pytest-asyncio 0.19.0
rfc3986        1.5.0
setuptools     63.2.0
sniffio        1.3.0
starlette      0.20.4
tomli          2.0.1

Sounds like pytest fixture is returning an async iterable instead the value in the yield.
Could it be caused by some bug in some version of some package, or is a problem of the asgi-lifespan? Or I mess up with my setting?

@florimondmanca
Copy link
Owner

Hi!

Yes, it’s likely the latest version of pytest-asyncio switched how async fixtures should be declared. I believe they should be @pytest_asyncio.fixture now, or something.

If you figure out this fixes the issue, I’d be happy to review a PR to update the README. :)

@netsmash
Copy link
Contributor Author

You were right about the problem and the solution.
I have updated the README.md in the PR #52

@florimondmanca
Copy link
Owner

This got closed by #52.

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

No branches or pull requests

2 participants