Adding [aliases] fails with error: invalid command 'xyz'

Adding [aliases] fails with error: invalid command 'xyz'

尝试将 cov = coverage report --show-missing 等快捷方式添加到 setup.cfg 的 [aliases] 部分会导致 python setup.py cov 失败并返回 error: invalid command 'coverage'需要什么额外的选项来支持这个?

版本信息:

$ python -V
Python 3.7.3
$ pip list | egrep 'setuptools|pip|coverage|pytest'
coverage           5.2.1
pip                20.2.2
pytest             5.4.3
pytest-html        2.1.1
pytest-metadata    1.10.0
setuptools         50.0.0

setup.cfg:

[aliases]
test = coverage run -m pytest --html=pytest-report.html --self-contained-html
cov = coverage report --show-missing
covhtml = coverage html --title "Coverage report - xyz"

[tool:pytest]
testpaths = tests

[coverage:run]
branch = True
source = pyapp

[options]
# ...
install_requires =
    Flask==1.1.*
    psycopg2==2.8.*
    requests==2.*
    werkzeug==1.*
    click==7.*
setup_requires =
    pytest-runner
tests_require =
    coverage
    pytest
    pytest-html

setup.cfg aliasessetup.py 创建别名,而不是一般命令。在你的情况下 python setup.py cov 等同于

python setup.py coverage report --show-missing

setup.py抱怨它没有命令coverage