{
  "id": "python/pytest-asyncio-not-installed",
  "signature": "async def functions are not natively supported.\nYou need to install a suitable plugin for your async framework, for example:\n  - anyio\n  - pytest-asyncio",
  "signature_zh": "不支持原生的 async def 函数。\n你需要为异步框架安装合适的插件，例如：\n  - anyio\n  - pytest-asyncio",
  "regex": "async\\ def\\ functions\\ are\\ not\\ natively\\ supported\\.\\\nYou\\ need\\ to\\ install\\ a\\ suitable\\ plugin\\ for\\ your\\ async\\ framework,\\ for\\ example:\\\n\\ \\ \\-\\ anyio\\\n\\ \\ \\-\\ pytest\\-asyncio",
  "domain": "python",
  "category": "install_error",
  "subcategory": null,
  "root_cause": "Pytest cannot run `async def` test functions without an async plugin. The test is collected but pytest refuses to execute it because the event loop is not managed.",
  "root_cause_type": "generic",
  "root_cause_zh": "在没有异步插件的情况下，pytest 无法运行 `async def` 测试函数。测试会被收集，但 pytest 拒绝执行，因为没有管理事件循环。",
  "versions": [
    {
      "version": "7.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The test function itself is still async, so pytest still rejects it during collection.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The setting is only read by pytest-asyncio; without the plugin installed the option is ignored and the error persists.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "Install the plugin and enable auto mode:\n\npip install pytest-asyncio\n\n# pytest.ini\n[pytest]\nasyncio_mode = auto",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use anyio instead:\n\npip install anyio\n\n# test file\nimport pytest\n\n@pytest.mark.anyio\nasync def test_thing():\n    ...",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}