{
  "id": "python/pytest-capture-assertion-error",
  "signature": "AssertionError: assert 4 == 5\n +  where 4 = <function calculate_sum.<locals>.<lambda> at 0x7f8b1c3d4a9>",
  "signature_zh": "断言错误：断言 4 等于 5，且 4 来自 lambda 函数",
  "regex": "AssertionError:\\ assert\\ 4\\ ==\\ 5\\\n\\ \\+\\ \\ where\\ 4\\ =\\ <function\\ calculate_sum\\.<locals>\\.<lambda>\\ at\\ 0x7f8b1c3d4a9>",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "pytest 在捕获断言时，错误地显示了 lambda 函数的内部表示，导致调试信息混乱，实际是逻辑错误",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest 在捕获断言时，错误地显示了 lambda 函数的内部表示，导致调试信息混乱，实际是逻辑错误",
  "versions": [
    {
      "version": "7.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "根本问题不在 lambda，而是断言逻辑本身错误，修改函数形式不能修复",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "只是隐藏了错误信息，没有解决断言失败的本质",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "检查函数实际返回值，修正断言条件。例如：assert calculate_sum(2,2) == 4",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.7,
      "how": "对于浮点数比较，使用 assert result == pytest.approx(5.0)",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-03-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}