{
  "id": "python/unittest-mock-assert-called-with-typeerror",
  "signature": "TypeError: 'NoneType' object is not callable when using mock.assert_called_with",
  "signature_zh": "类型错误：使用 mock.assert_called_with 时 'NoneType' 对象不可调用",
  "regex": "TypeError:\\ 'NoneType'\\ object\\ is\\ not\\ callable\\ when\\ using\\ mock\\.assert_called_with",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "The mock object is not properly configured or is being replaced by a non-callable value (e.g., None) before the assertion is made.",
  "root_cause_type": "generic",
  "root_cause_zh": "模拟对象未正确配置，或在断言之前被非可调用值（例如 None）替换。",
  "versions": [
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding more mock assertions without checking mock creation",
      "why_fails": "The core issue is the mock object itself; additional assertions will fail similarly.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using patch decorator incorrectly and assuming mock is automatically callable",
      "why_fails": "If patch replaces the object with a non-callable, the mock will not be callable.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the mock is created with 'autospec=True' to maintain callable signature.",
      "success_rate": 0.85,
      "how": "mock = unittest.mock.MagicMock(autospec=True); mock.assert_called_with(args)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Verify the mock is not overwritten by using patch with return_value set explicitly.",
      "success_rate": 0.8,
      "how": "with unittest.mock.patch('module.function', return_value=mock_callable): ...",
      "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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}