{
  "id": "python/pytest-mock-not-called",
  "signature": "AssertionError: Expected 'send_email' to have been called once. Called 0 times.",
  "signature_zh": "AssertionError: 预期 'send_email' 被调用一次。实际调用 0 次。",
  "regex": "AssertionError:\\ Expected\\ 'send_email'\\ to\\ have\\ been\\ called\\ once\\.\\ Called\\ 0\\ times\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The mocked function was not called because the code under test uses a different reference (e.g., imported directly) or the test logic does not reach the call.",
  "root_cause_type": "generic",
  "root_cause_zh": "被 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": "The patch must target where the function is looked up, not where it's defined.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "May not work if the code uses a module-level import.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "If myapp/service.py has 'from myapp.utils import send_email', patch 'myapp.service.send_email'.\nIf it has 'import myapp.utils', patch 'myapp.utils.send_email'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Add a print before the call in the source code, or use pdb to step through.",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}