fix async_generator error by making the app fixture async#336
fix async_generator error by making the app fixture async#336john0isaac wants to merge 7 commits intopallets:mainfrom
Conversation
We are yielding the app fixture but not passing it as an argument which seems to break the second part of the documentation where we attempt to access the `test_client()` it gives an async_generator. ```bash AttributeError: 'async_generator' object has no attribute 'test_client' ```
|
Does this depend on the pytest-asyncio mode you are using? As it works for me without this change here |
|
@pgjones I'm using the default values for everything. I will reproduce and get back to you with the detailed versions of everything in an isolated environment. This is my working setup here. Have you tested this recently? Maybe it changed in the latest versions but was working previously.. My change works on Python 3.10, 3.11, 3.12 but I will reproduce again and leave detailed comment with it. |
|
@pgjones I did look further at your example, you are not following the documentation on how to configure a test. To configure your test you are using the https://github.com/pgjones/tozo/blob/main/backend/src/backend/run.py#L22 The documentation clearly instructs to use the So, There are two solutions:
|
|
I can confirm that I faced the same issue following the documentation and this simple fix solved it |


The app fixture is not created as an async fixture which results in breaking the second part of the documentation where we attempt to access the
test_client()it gives an async_generator.This PR fixes that to pass the tests
Checklist:
CHANGES.rstsummarizing the change and linking to the issue... versionchanged::entries in any relevant code docs.pre-commithooks and fix any issues.pytestandtox, no tests failed.