{
  "id": "python/pytest-assertion-rewrite-failed",
  "signature": "AssertionError: assert {'a': 1} == {'a': 1}\n  Omitting 1 identical items, use -vv to show\n  Full diff:\n  - {'a': 1}\n  + {'a': 1}\n  ?  ^   ^\n  + {'a': 1}\n  ?  ^   ^",
  "signature_zh": "AssertionError: assert {'a': 1} == {'a': 1}\n  省略 1 个相同项，使用 -vv 显示\n  完整差异:\n  - {'a': 1}\n  + {'a': 1}\n  ?  ^   ^\n  + {'a': 1}\n  ?  ^   ^",
  "regex": "AssertionError:\\ assert\\ \\{'a':\\ 1\\}\\ ==\\ \\{'a':\\ 1\\}\\\n\\ \\ Omitting\\ 1\\ identical\\ items,\\ use\\ \\-vv\\ to\\ show\\\n\\ \\ Full\\ diff:\\\n\\ \\ \\-\\ \\{'a':\\ 1\\}\\\n\\ \\ \\+\\ \\{'a':\\ 1\\}\\\n\\ \\ \\?\\ \\ \\^\\ \\ \\ \\^\\\n\\ \\ \\+\\ \\{'a':\\ 1\\}\\\n\\ \\ \\?\\ \\ \\^\\ \\ \\ \\^",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The assertion compares objects that look equal in repr but differ in type or nested identity (e.g., int vs bool, numpy array vs list, or a custom __eq__ that returns a non-bool). pytest's assertion rewriting hides the real difference.",
  "root_cause_type": "generic",
  "root_cause_zh": "断言比较的对象在 repr 中看似相等，但在类型或嵌套标识上不同（如 int 与 bool、numpy 数组与 list，或自定义 __eq__ 返回非布尔值）。pytest 的断言重写隐藏了真实差异。",
  "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": "Identity comparison almost always fails for equal-but-distinct objects and produces a more confusing error.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Only changes the error formatting; the underlying inequality is still there.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Print the types and use a type-strict comparison:\n\ndef test_x():\n    actual = get()\n    assert type(actual) is dict and actual == {'a': 1}, f\"{type(actual)=} {actual=}\"",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "For numpy/pandas, use the dedicated assertion helpers:\n\nimport numpy as np\nnp.testing.assert_array_equal(actual, expected)\nimport pandas as pd\npd.testing.assert_frame_equal(df1, df2)",
      "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-09-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}