{
  "id": "python/pytest-teardown-error",
  "signature": "ERROR at teardown of test_example",
  "signature_zh": "test_example 的 teardown 阶段出错",
  "regex": "ERROR\\ at\\ teardown\\ of\\ test_example",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The teardown phase of a fixture or test raised an exception. This often happens when cleanup code (closing connections, deleting files) fails due to prior test failures or resource leaks.",
  "root_cause_type": "generic",
  "root_cause_zh": "夹具或测试的清理阶段抛出异常。这通常发生在清理代码（关闭连接、删除文件）因先前测试失败或资源泄漏而失败时。",
  "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": "This flag only affects collection errors, not teardown errors. The teardown failure will still be reported.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This leaves resources open, causing cascading failures in subsequent tests (e.g., database locks, port conflicts).",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "@pytest.fixture\ndef resource():\n    r = acquire()\n    yield r\n    try:\n        r.release()\n    except Exception as e:\n        logging.warning(f'Teardown failed: {e}')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "@pytest.fixture\ndef resource(request):\n    r = acquire()\n    def cleanup():\n        try:\n            r.release()\n        except Exception:\n            pass\n    request.addfinalizer(cleanup)\n    return r",
      "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-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}