{
  "id": "python/unittest-mock-return-value-not-asserted",
  "signature": "AssertionError: Expected mock to have been called once. Called 0 times.",
  "signature_zh": "断言错误：期望 mock 被调用一次。实际调用 0 次。",
  "regex": "AssertionError:\\ Expected\\ mock\\ to\\ have\\ been\\ called\\ once\\.\\ Called\\ 0\\ times\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The mock object's call count doesn't match the expected number, often due to incorrect patch target or logic.",
  "root_cause_type": "generic",
  "root_cause_zh": "mock 对象的调用次数与预期不符，通常是由于补丁目标错误或逻辑错误。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This masks the real problem of why the code isn't calling the mock.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The test becomes ineffective.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "with patch('module.function') as mock_func:\n    call_code()\n    mock_func.assert_called_once()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "mock_func.assert_any_call(arg1, arg2)",
      "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": "2025-02-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}