{
  "id": "python/unittest-assertion-always-true-no-self",
  "signature": "test_something (tests.test_x.TestX.test_something) ... ok\n# but the test body contains: assertEqual(1, 2) and never runs",
  "signature_zh": "test_something (tests.test_x.TestX.test_something) ... ok\n# 但测试体包含 assertEqual(1, 2) 却从未执行",
  "regex": "test_something\\ \\(tests\\.test_x\\.TestX\\.test_something\\)\\ \\.\\.\\.\\ ok\\\n\\#\\ but\\ the\\ test\\ body\\ contains:\\ assertEqual\\(1,\\ 2\\)\\ and\\ never\\ runs",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A helper method named like a test (test_*) inside the TestCase lacks the `self` parameter or is defined as a staticmethod, so unittest treats it as a test but it fails silently or is skipped.",
  "root_cause_type": "generic",
  "root_cause_zh": "TestCase 中名为 test_* 的辅助方法缺少 `self` 参数或被定义为 staticmethod，unittest 将其当作测试但静默失败或被跳过。",
  "versions": [
    {
      "version": "3.8",
      "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": "Renaming fixes discovery but does not explain why the assertions were silently skipped; other tests may still be misnamed.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides the real issue; the method is still collected as a test and reported as skipped, polluting results.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "class TestX(unittest.TestCase):\n    def _build_payload(self):\n        return {'k': 1}\n\n    def test_payload(self):\n        self.assertEqual(self._build_payload(), {'k': 1})",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "def build_payload():\n    return {'k': 1}\n\nclass TestX(unittest.TestCase):\n    def test_payload(self):\n        self.assertEqual(build_payload(), {'k': 1})",
      "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": "true",
  "first_seen": "2024-07-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}