{
  "id": "python/unittest-assertraises-no-context",
  "signature": "TypeError: assertRaises() missing 1 required positional argument: 'callable'",
  "signature_zh": "TypeError: assertRaises() 缺少 1 个必需的位置参数: 'callable'",
  "regex": "TypeError:\\ assertRaises\\(\\)\\ missing\\ 1\\ required\\ positional\\ argument:\\ 'callable'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "`assertRaises` is used as `with self.assertRaises(ValueError):` but the exception type is passed as a string or the callable form is used incorrectly.",
  "root_cause_type": "generic",
  "root_cause_zh": "`assertRaises` 以 `with self.assertRaises(ValueError):` 形式使用，但异常类型被传为字符串或可调用形式使用不当。",
  "versions": [
    {
      "version": "3.9",
      "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": "Strings are not exception classes; raises TypeError or fails silently.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Catches all exceptions and hides real bugs.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.97,
      "how": "Use the context manager form correctly:\nwith self.assertRaises(ValueError):\n    parse('bad')\n\nOr the callable form:\nself.assertRaises(ValueError, parse, 'bad')",
      "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.89,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-03-06",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}