pytest asyncio test skipped: anyio plugin setup
Fixes pytest-asyncio/anyio tests that get skipped instead of running. Use it when async tests report 'skipped' with no clear reason. Not for async test failures or trio-specific issues.
TL;DR
An async test gets skipped when no plugin claims it: either the anyio/asyncio plugin is not installed, or the test lacks the marker/fixture that tells the plugin to run it. Install anyio plus the pytest anyio plugin support, mark tests with pytest.mark.anyio, and provide the anyio_backend fixture (usually parametrized as asyncio) in conftest. Then check the skip reason in verbose output; "skipped" with no marker applied is the signature of this exact problem.
The query
pytest asyncio test skipped: anyio plugin setupUse this when
- Async tests show as SKIPPED instead of running
- Setting up anyio-based async tests for the first time
- Tests pass locally but skip in CI (plugin missing from CI env)
Not for
- Async tests that run and fail
- Choosing between asyncio and trio backends
- Sync test skip markers (
pytest.mark.skip)
Steps
- Run with
-v -rsto surface skip reasons and confirm the plugin is installed (pip show anyio, check installed pytest plugins). Expected output: skip reason shown; you confirm whether the anyio plugin is present. - Add the
anyio_backendfixture to conftest (e.g. params['asyncio']) and mark async tests withpytest.mark.anyio. Expected output: the plugin now claims the tests instead of skipping them. - Re-run the async tests and confirm they execute (PASSED/FAILED, not SKIPPED). Expected output: tests run; any failures are real test failures, not skips.
- Pin the plugin in your test dependencies so CI installs it too. Expected output: CI runs the async tests instead of silently skipping them.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_Bq4OYrGtBvrM8uZmVJPnPw