{
  "id": "python/pytest-fixure-teardown-error",
  "signature": "Failed: fixture 'client' not found in teardown",
  "signature_zh": "失败：在 teardown 阶段找不到夹具 'client'",
  "regex": "Failed:\\ fixture\\ 'client'\\ not\\ found\\ in\\ teardown",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "在 fixture 的 teardown 代码中尝试访问另一个不存在的 fixture",
  "root_cause_type": "generic",
  "root_cause_zh": "在 fixture 的 teardown 代码中尝试访问另一个不存在的 fixture",
  "versions": [
    {
      "version": "7.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "teardown 阶段不应创建新 fixture",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "会导致资源泄漏",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "@pytest.fixture\ndef client():\n    yield create_client()\n    # teardown code",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "def client(request):\n    c = create_client()\n    request.addfinalizer(c.close)\n    return c",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-09",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}