{
  "id": "python/unittest-patch-decorator-argument-order",
  "signature": "TypeError: test_foo() missing 1 required positional argument: 'mock_open'",
  "signature_zh": "TypeError: test_foo() 缺少 1 个必需的位置参数: 'mock_open'",
  "regex": "TypeError:\\ test_foo\\(\\)\\ missing\\ 1\\ required\\ positional\\ argument:\\ 'mock_open'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Multiple @patch decorators inject mocks in bottom-up order, but the test signature lists them top-down, so arguments are bound to the wrong parameters.",
  "root_cause_type": "generic",
  "root_cause_zh": "多个 @patch 装饰器按从下到上的顺序注入 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": "Fixes one test but the convention is undocumented; other tests in the file break the same way.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Mocks are positional; *args swallows them but makes assertions awkward and hides binding bugs.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "@patch('myapp.db.open')\n@patch('myapp.fs.read')\ndef test_foo(mock_read, mock_open):\n    # mock_read corresponds to the bottom decorator\n    ...",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "def test_foo():\n    with patch('myapp.fs.read') as mock_read, \\\n         patch('myapp.db.open') as mock_open:\n        ...",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-07",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}