{
  "id": "python/pytest-assert-repr-failure",
  "signature": "AssertionError: assert <Mock name='mock()' id='140735234567890'> == 5",
  "signature_zh": "断言错误：断言 <Mock name='mock()' id='140735234567890'> == 5",
  "regex": "AssertionError:\\ assert\\ <Mock\\ name='mock\\(\\)'\\ id='140735234567890'>\\ ==\\ 5",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "A test is comparing a mock object to a value, likely because the mock was not set up to return a value, so it returns another mock by default.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试将模拟对象与值进行比较，可能是因为模拟对象未设置返回值，因此默认返回另一个模拟对象。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Comparing the mock to itself using `is`",
      "why_fails": "This does not test the actual behavior; it only checks identity.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting return_value to a string like '5'",
      "why_fails": "This changes the type; the test expects an integer 5.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set the mock's return_value to the expected integer value",
      "success_rate": 0.95,
      "how": "mock = MagicMock(return_value=5)\nresult = mock()\nassert result == 5\nOr: mock.return_value = 5",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure the code under test is calling the mock correctly",
      "success_rate": 0.85,
      "how": "Debug to see if the mock is being called. If not, the test may be comparing the mock object itself instead of its return value.",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-11-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}