{
  "id": "python/unittest-subtest-failure-not-reported",
  "signature": "AssertionError: 0 != 1 : SubTest failed",
  "signature_zh": "断言错误：0 != 1：子测试失败",
  "regex": "AssertionError:\\ 0\\ !=\\ 1\\ :\\ SubTest\\ failed",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A subTest failure is not being properly reported because the subTest block doesn't raise an assertion error correctly.",
  "root_cause_type": "generic",
  "root_cause_zh": "子测试失败未被正确报告，因为 subTest 块没有正确引发断言错误。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This loses granularity of test reporting.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This may swallow the exception and not mark the test as failed.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "for i in range(5):\n    with self.subTest(i=i):\n        self.assertEqual(i, 0)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "@pytest.mark.parametrize('i', range(5))\ndef test_foo(i):\n    assert i == 0",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-05-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}