微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

添加[别名]失败,并显示以下错误:无效命令'xyz'

如何解决添加[别名]失败,并显示以下错误:无效命令'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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。