{
  "id": "python/pytest-monkeypatch-undo-error",
  "signature": "RuntimeError: monkeypatch already undone, cannot undo again",
  "signature_zh": "运行时错误：monkeypatch 已被撤销，无法再次撤销",
  "regex": "RuntimeError:\\ monkeypatch\\ already\\ undone,\\ cannot\\ undo\\ again",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "在测试中多次调用 monkeypatch.undo()，或在夹具 teardown 后手动调用。",
  "root_cause_type": "generic",
  "root_cause_zh": "在测试中多次调用 monkeypatch.undo()，或在夹具 teardown 后手动调用。",
  "versions": [
    {
      "version": "7.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "掩盖了逻辑错误，且可能影响后续测试。",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "pytest 自动管理，无需手动。",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 1.0,
      "how": "让 pytest 自动撤销，不要在测试中显式调用 monkeypatch.undo()。",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "如果必须手动，在 finally 中只调用一次 undo。",
      "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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-09-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}