{
  "id": "python/unittest-assertraises-wrong-exception",
  "signature": "AssertionError: <class 'ValueError'> not raised",
  "signature_zh": "AssertionError: <class 'ValueError'> 未引发",
  "regex": "AssertionError:\\ <class\\ 'ValueError'>\\ not\\ raised",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The code under test did not raise the expected exception. This could be because the code path was not triggered, the exception type is different, or the code silently handles the error.",
  "root_cause_type": "generic",
  "root_cause_zh": "被测代码未引发预期的异常。这可能是因为代码路径未触发、异常类型不同，或代码静默处理了错误。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This broadens the assertion and may pass even when the wrong exception is raised, hiding bugs.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This bypasses assertRaises entirely and does not verify the exception type correctly.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "with self.assertRaises(ValueError) as cm:\n    my_function(invalid_input)\nself.assertEqual(str(cm.exception), 'expected message')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "import pytest\n\nwith pytest.raises(ValueError, match='expected message'):\n    my_function(invalid_input)",
      "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-01-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}