{
  "id": "python/pytest-assert-dict-equality",
  "signature": "AssertionError: assert {'a': 1, 'b': 2} == {'b': 2, 'a': 1}",
  "signature_zh": "断言错误：assert {'a': 1, 'b': 2} == {'b': 2, 'a': 1}",
  "regex": "AssertionError:\\ assert\\ \\{'a':\\ 1,\\ 'b':\\ 2\\}\\ ==\\ \\{'b':\\ 2,\\ 'a':\\ 1\\}",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "字典比较看似相同但顺序不同，pytest 的断言重写可能因顺序导致误报，但实际字典相等。",
  "root_cause_type": "generic",
  "root_cause_zh": "字典比较看似相同但顺序不同，pytest 的断言重写可能因顺序导致误报，但实际字典相等。",
  "versions": [
    {
      "version": "7.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "字典无法排序，且不必要。",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "如果字典顺序影响某些逻辑，可能掩盖问题。",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 1.0,
      "how": "Python 字典相等性不依赖顺序，`assert dict1 == dict2` 应该通过，检查是否有其他差异。",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "如果值包含浮点数，使用 `assert actual == pytest.approx(expected)`。",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-08-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}