{
  "id": "python/unittest-assertion-rewrite-missing",
  "signature": "AssertionError: False is not true : expected True",
  "signature_zh": "AssertionError: False 不为 true : 期望为 True",
  "regex": "AssertionError:\\ False\\ is\\ not\\ true\\ :\\ expected\\ True",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "In unittest, `self.assertTrue(x)` on a falsy value produces a generic message; pytest's assertion rewriting does not apply to unittest.TestCase methods, so diffs are opaque.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 unittest 中，对假值调用 `self.assertTrue(x)` 会生成通用消息；pytest 的断言重写不适用于 unittest.TestCase 方法，因此差异不清晰。",
  "versions": [
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.11",
      "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": "Disables assertion rewriting entirely, making messages even less informative.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Adds noise to test output and does not fix the underlying opaque failure; CI logs become harder to scan.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Global monkeypatch affects all tests and is fragile across unittest versions.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "def test_something():\n    result = compute()\n    assert result == expected  # pytest shows rich diff",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "self.assertEqual(result, expected)\nself.assertIn(item, container)\nself.assertIsNotNone(obj)",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}