{
  "id": "python/unittest-mock-magicmock-assertion",
  "signature": "AssertionError: expected call not found.\nExpected: fetch('https://api.example.com')\n  Actual: fetch()",
  "signature_zh": "AssertionError: 未找到期望的调用。\n期望: fetch('https://api.example.com')\n  实际: fetch()",
  "regex": "AssertionError:\\ expected\\ call\\ not\\ found\\.\\\nExpected:\\ fetch\\('https://api\\.example\\.com'\\)\\\n\\ \\ Actual:\\ fetch\\(\\)",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "assert_called_with compares exact positional and keyword arguments. The actual call passed different arguments (e.g., a URL object instead of a string) or the mock was reset/reconfigured between the call and the assertion.",
  "root_cause_type": "generic",
  "root_cause_zh": "assert_called_with 比较精确的位置参数和关键字参数。实际调用传入了不同的参数（例如 URL 对象而非字符串），或者 mock 在调用和断言之间被重置/重新配置。",
  "versions": [
    {
      "version": "3.8",
      "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": "Only checks call count, not arguments; the bug (wrong URL) goes undetected.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "matching.ANY makes the assertion always pass and hides the real argument mismatch.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "mock_fetch.assert_called_once()\nargs, kwargs = mock_fetch.call_args\nassert str(args[0]) == 'https://api.example.com'",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.82,
      "how": "from unittest.mock import call, ANY\nmock_fetch.assert_called_with(ANY)\nassert mock_fetch.call_args.args[0].__str__().endswith('/api.example.com')",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}