python
runtime_error
ai_generated
true
SetuptoolsDeprecationWarning:'test' 命令已弃用。请改用 pytest。
SetuptoolsDeprecationWarning: 'test' command is deprecated. Use pytest instead.
ID: python/setuptools-deprecated-test-command
80%修复率
87%置信度
0证据数
2024-01-22首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
setuptools 58+ 移除了 setup.py 内置的 'test' 命令集成。运行 'python setup.py test' 会触发此弃用警告,并在 setuptools 72+ 中彻底失败。
English
setuptools 58+ removed the built-in 'test' command integration with setup.py. Running 'python setup.py test' triggers this deprecation and will fail outright in setuptools 72+.
解决方案
-
98% 成功率
Run pytest directly: python -m pytest tests/ . Configure pytest via pyproject.toml [tool.pytest.ini_options].
-
92% 成功率
Use tox for multi-env testing: pip install tox && tox. Define [tox] envlist in tox.ini and let tox invoke pytest.
无效尝试
常见但无效的做法:
-
70% 失败
Downgrading setuptools breaks other packages requiring modern setuptools (e.g. numpy, cryptography) and leaves you on an unsupported release.
-
85% 失败
tests_require was removed alongside the test command; it no longer has any effect.