{
  "id": "python/unittest-test-discovery-zero-tests",
  "signature": "Ran 0 tests in 0.000s\n\nNO TESTS RAN",
  "signature_zh": "Ran 0 tests in 0.000s\n\nNO TESTS RAN",
  "regex": "Ran\\ 0\\ tests\\ in\\ 0\\.000s\\\n\\\nNO\\ TESTS\\ RAN",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "unittest discovery requires test files to match `test*.py` and classes to subclass `unittest.TestCase`. Common causes: file named `tests_foo.py`, class not inheriting TestCase, or discovery started from the wrong directory without `-s`.",
  "root_cause_type": "generic",
  "root_cause_zh": "unittest 发现要求测试文件匹配 `test*.py`，且类必须继承 `unittest.TestCase`。常见原因：文件名为 `tests_foo.py`、类未继承 TestCase、或从错误目录启动发现且未使用 `-s`。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Discovery only collects TestCase subclasses; a plain class with test_ methods is ignored.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Default start dir is '.', but if tests live in a subdir not on the path, discovery finds nothing.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.96,
      "how": "# tests/test_math.py\nimport unittest\n\nclass TestMath(unittest.TestCase):\n    def test_add(self):\n        self.assertEqual(1 + 1, 2)\n\n# run\npython -m unittest discover -s tests -p \"test*.py\" -v",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.93,
      "how": "python -m unittest tests.test_math -v\n# or\npython -m unittest tests.test_math.TestMath.test_add",
      "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-04-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}