python runtime_error ai_generated true

SetuptoolsDeprecationWarning: 'test' command is deprecated. Use pytest instead.

ID: python/setuptools-deprecated-test-command

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-01-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

Root Cause

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+.

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Downgrading setuptools breaks other packages requiring modern setuptools (e.g. numpy, cryptography) and leaves you on an unsupported release.

  2. 85% fail

    tests_require was removed alongside the test command; it no longer has any effect.