# Ran 0 tests in 0.000s（未运行任何测试）

- **ID:** `python/unittest-discovery-no-tests-ran`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

unittest discover 未找到测试模块：匹配模式不符、起始目录不是包（旧版本缺少 __init__.py），或文件名不符合 test*.py。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.10 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (92% 成功率)
   ```
   python -m unittest discover -s tests -p 'test_*.py' -v
# Ensure tests/ has __init__.py if using package-relative imports
   ```
2. **** (88% 成功率)
   ```
   git mv tests/foo_tests.py tests/test_foo.py
python -m unittest discover -v
   ```

## 无效尝试

- **** — The methods are never executed because discovery fails before collection; prints never run. (85% 失败率)
- **** — Default pattern is 'test*.py' (prefix). 'mytest.py' won't match; only 'test_*.py' or 'test*.py' work. (60% 失败率)
