{
  "id": "python/unittest-mock-patch-object-attribute",
  "signature": "AttributeError: <module 'myapp' from '...'> does not have attribute 'config'",
  "signature_zh": "属性错误：<module 'myapp' from '...'> 没有属性 'config'",
  "regex": "AttributeError:\\ <module\\ 'myapp'\\ from\\ '\\.\\.\\.'>\\ does\\ not\\ have\\ attribute\\ 'config'",
  "domain": "python",
  "category": "attribute_error",
  "subcategory": null,
  "root_cause": "在 patch.object 中指定了不存在的属性，或模块被错误导入。",
  "root_cause_type": "generic",
  "root_cause_zh": "在 patch.object 中指定了不存在的属性，或模块被错误导入。",
  "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": "",
      "why_fails": "修改生产代码，且可能不需要。",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "patch 需要字符串路径，可能同样出错。",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "在测试前 `hasattr(myapp, 'config')`，确保存在再 patch。",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "`patch('myapp.config')` 如果属性在模块级别。",
      "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-10-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}