{
  "id": "python/unittest-subtest-failure-swallowed",
  "signature": "FAILED (failures=0)\n# but subTest failures printed:\nFAIL: test_batch (tests.test_batch.TestBatch.test_batch) (i=3)\nAssertionError: 3 != 4",
  "signature_zh": "FAILED (failures=0)\n# 但打印了 subTest 失败:\nFAIL: test_batch (tests.test_batch.TestBatch.test_batch) (i=3)\nAssertionError: 3 != 4",
  "regex": "FAILED\\ \\(failures=0\\)\\\n\\#\\ but\\ subTest\\ failures\\ printed:\\\nFAIL:\\ test_batch\\ \\(tests\\.test_batch\\.TestBatch\\.test_batch\\)\\ \\(i=3\\)\\\nAssertionError:\\ 3\\ !=\\ 4",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "subTest failures are recorded against the parent test but some runners or custom result classes do not increment the failures counter, so the summary reports failures=0 even though individual subtests failed.",
  "root_cause_type": "generic",
  "root_cause_zh": "subTest 失败记录在父测试上，但某些运行器或自定义结果类不会增加 failures 计数器，导致摘要显示 failures=0 而个别子测试实际失败。",
  "versions": [
    {
      "version": "3.10",
      "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": "Defeats the purpose of subTest (continue-on-failure) and stops at the first failing case.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The process may still exit 0 when failures counter is zero, so CI passes a broken suite.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Run with a result class that counts subtests, or use pytest which reports them:\n\npython -m pytest tests/test_batch.py -v",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Inspect result.failures + result.errors + subtest count in a custom runner:\n\nresult = unittest.TextTestRunner().run(suite)\nassert not result.failures and not result.errors",
      "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.8,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2025-05-19",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}