{
  "id": "python/pytest-assertion-rewrite-cache-stale",
  "signature": "AssertionError: assert <myapp.models.User object at 0x7f8b1c0d5e50> == <myapp.models.User object at 0x7f8b1c0d5e50>\nE   AttributeError: 'User' object has no attribute '__eq__'",
  "signature_zh": "AssertionError: assert <myapp.models.User object at 0x7f8b1c0d5e50> == <myapp.models.User object at 0x7f8b1c0d5e50>\nE   AttributeError: 'User' 对象没有属性 '__eq__'",
  "regex": "AssertionError:\\ assert\\ <myapp\\.models\\.User\\ object\\ at\\ 0x7f8b1c0d5e50>\\ ==\\ <myapp\\.models\\.User\\ object\\ at\\ 0x7f8b1c0d5e50>\\\nE\\ \\ \\ AttributeError:\\ 'User'\\ object\\ has\\ no\\ attribute\\ '__eq__'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "The assertion compares two objects without __eq__ defined, so identity comparison fails. The confusing part is that pytest's assertion rewrite shows the repr, making it look like they should be equal.",
  "root_cause_type": "generic",
  "root_cause_zh": "断言比较两个未定义 __eq__ 的对象，因此身份比较失败。令人困惑的是 pytest 的断言重写会显示 repr，使其看起来应该相等。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "id() comparison only checks identity; if the test intends value equality, this is a false pass.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Same identity semantics; does not fix the missing __eq__ for value comparison.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "class User:\n    def __init__(self, id):\n        self.id = id\n    def __eq__(self, other):\n        return isinstance(other, User) and self.id == other.id",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "assert result.id == expected.id\nassert result.name == expected.name",
      "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-05-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}