Repository navigation
fix(python-aiohttp): use async client fixture for pytest-aiohttp 1.x (fixes Python Server CI) - #25372
Merged
wing328 merged 1 commit intoOct 23, 2026
Conversation
… 1.x pytest-aiohttp 1.x switched to pytest-asyncio and removed the deprecated `loop` fixture in 1.1.0, causing `fixture 'loop' not found` errors in generated tests. Update `conftest.mustache` to define `client` as an async fixture awaiting `aiohttp_client(app.app)`, configure `asyncio_mode = auto` in `tox.mustache`, and require `pytest-aiohttp>=1.0.0` and `pytest-asyncio>=0.17.2` in `test-requirements.mustache`. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
|
thanks for the fix, which has been merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Python Server workflow (
.github/workflows/samples-python-server.yaml) fails on master and on the v7.26.0 / v7.25.0 release runs. It also fails on PRs that touch the python-aiohttp samples, for example #25362. Every generated test errors at setup with:The cause is the generated
tests/conftest.py: itsclientfixture takesloopand callsloop.run_until_complete(aiohttp_client(app.app)), whiletest-requirements.txtasks forpytest-aiohttp>=0.3.0with no upper bound. pytest-aiohttp 1.0 moved to pytest-asyncio, madeaiohttp_clientan async fixture and deprecatedloop, and 1.1.0 removedloop(see its CHANGES and README).Changes (python-aiohttp)
conftest.mustache:clientbecomes an async fixture that doesreturn await aiohttp_client(app.app), as pytest-aiohttp's README recommends.tox.mustache: add[pytest] asyncio_mode = auto(non-nose branch), so the async fixture and tests run under pytest-asyncio's default strict mode. Plainpytestalso readstox.ini; the generated project has no competingpytest.ini/setup.cfg/pyproject.toml.test-requirements.mustache:pytest-aiohttp>=1.0.0andpytest-asyncio>=0.17.2.pytest~=7.1.0is unchanged. pip resolves this to a compatible set, for example pytest 7.1.3, pytest-asyncio 0.23.8 and pytest-aiohttp 1.1.0.samples/server/petstore/python-aiohttp-srclayout(tests/conftest.py,tox.ini,test-requirements.txt).I chose this over pinning
pytest-aiohttp<1, which would keep relying on an API that pytest-aiohttp has removed.Verification
With Python 3.9.25 (the version the workflow uses), running
make test-allinsamples/server/petstore/python-aiohttp-srclayoutin a fresh copy:9 skipped, 11 errors(allfixture 'loop' not found), with pytest-aiohttp 1.1.0, pytest 7.1.3 and pytest-asyncio 0.23.811 passed, 9 skipped,py3: OKOnly that environment was exercised, not every version combination the requirements allow.
Python*Test/AbstractPython*Testpass; no Java code changed. WithuseNoseenabled, dependencies and the test command are unchanged, but the conftest change applies to both modes, as before.PR checklist
bin/configs/python-aiohttp*.yaml(the only affected generator) and committed the three changed files. Generator options and docs are unchanged.cc @cbornet @tomplus @krjakbrjak @fa0311 (Python technical committee)
Parts of this change were drafted with AI coding assistants (Devin, Claude Code) and reviewed and verified by me.
🤖 Generated with Claude Code
Summary by cubic
Fixes the Python Server CI, which failed on master and the v7.25.0/v7.26.0 release runs because generated python-aiohttp tests rely on the
loopfixture that pytest-aiohttp 1.1.0 removed.clientfixture as async and awaitsaiohttp_client(app.app)instead ofloop.run_until_complete.asyncio_mode = autoto the generatedtox.iniso async fixtures run under pytest-asyncio.pytest-aiohttp>=1.0.0andpytest-asyncio>=0.17.2in generated test requirements.python-aiohttp-srclayoutsample.With Python 3.9.25, the sample's tests go from
9 skipped, 11 errorsto11 passed, 9 skipped.Written for commit 0022c0d. Summary will update on new commits.