Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 添加[别名]失败,错误为:命令无效';xyz';_Python_Python 3.x_Setuptools_Setup.py - Fatal编程技术网

Python 添加[别名]失败,错误为:命令无效';xyz';

Python 添加[别名]失败,错误为:命令无效';xyz';,python,python-3.x,setuptools,setup.py,Python,Python 3.x,Setuptools,Setup.py,尝试向setup.cfg部分添加快捷方式,如cov=coverage report--show missing,会导致python setup.py cov失败,并出现错误:无效命令“coverage”需要哪些其他选项来支持此功能? 版本信息: $ python -V Python 3.7.3 $ pip list | egrep 'setuptools|pip|coverage|pytest' coverage 5.2.1 pip 20.2.2

尝试向setup.cfg部分添加快捷方式,如
cov=coverage report--show missing
,会导致
python setup.py cov
失败,并出现
错误:无效命令“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.py
创建别名,而不是常规命令。在您的情况下,
python setup.py cov
相当于

python setup.py coverage report --show-missing

并且
setup.py
抱怨它没有覆盖范围的命令
coverage

Hm,好的。但是我在几篇文章中看到了
[aliases]test=pytest
pytest
不是正式的子命令,对吗?那么,是什么让这个案例起作用呢?(第二个问题——我想替代方案应该是包装器脚本或shell
alias
。还有其他特定于Python项目的想法吗?)我想到的是节点的
脚本
key in package.json,它可以让您为想要的几乎任何
npm
子命令添加别名。关于pytest-我尝试了别名,但它对我不起作用;如果
setup.py
tests\u require=['pytest'],
那么它可能会起作用,因此
python setup.py pytest
可以起作用。edit:我突然想到,在这里使用Makefile非常适合在项目中为常用命令添加别名。