# SetuptoolsDeprecationWarning：'test' 命令已弃用。请改用 pytest。

- **ID:** `python/setuptools-deprecated-test-command`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

setuptools 58+ 移除了 setup.py 内置的 'test' 命令集成。运行 'python setup.py test' 会触发此弃用警告，并在 setuptools 72+ 中彻底失败。

## 版本兼容性

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

## 解决方案

1. **** (98% 成功率)
   ```
   Run pytest directly: python -m pytest tests/ . Configure pytest via pyproject.toml [tool.pytest.ini_options].
   ```
2. **** (92% 成功率)
   ```
   Use tox for multi-env testing: pip install tox && tox. Define [tox] envlist in tox.ini and let tox invoke pytest.
   ```

## 无效尝试

- **** — Downgrading setuptools breaks other packages requiring modern setuptools (e.g. numpy, cryptography) and leaves you on an unsupported release. (70% 失败率)
- **** — tests_require was removed alongside the test command; it no longer has any effect. (85% 失败率)
