{
  "id": "python/unittest-mock-return-value-not-set",
  "signature": "AssertionError: Expected mock to be called once. Called 0 times.",
  "signature_zh": "断言错误：期望mock被调用一次，实际调用0次。",
  "regex": "AssertionError:\\ Expected\\ mock\\ to\\ be\\ called\\ once\\.\\ Called\\ 0\\ times\\.",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "在使用unittest.mock时，mock对象没有正确配置return_value或side_effect，导致测试中的调用没有被正确模拟，实际调用次数为0。",
  "root_cause_type": "generic",
  "root_cause_zh": "unittest.mock中，mock对象未设置return_value或side_effect，导致调用未被模拟，实际调用次数为0。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "导入错误不是主要原因，mock配置才是根本问题。",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "这掩盖了问题，而不是修复mock配置。",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "mock_obj.return_value = 'expected_value'\nresult = mock_obj()\nassert result == 'expected_value'",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "with patch('module.func') as mock_func:\n    mock_func.side_effect = [1, 2]\n    assert module.func() == 1",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}