[英]How to run a module from the command line with options?
Modules in python can be run from the pipeline with the -m
option : python 中的模块可以使用
-m
选项从管道运行:
python -m pytest
This runs pytest with the advantage that the current directory is added to sys.path .这运行 pytest 的优点是将当前目录添加到 sys.path 。
Now I want to run pytest
with the -verbose
option, but surrounding it with quotes/ticks does not work:现在我想用
-verbose
选项运行pytest
,但是用引号/刻度包围它不起作用:
python -m pytest -verbose
python -m "pytest -verbose"
python -m 'pytest -verbose'
python -m `pytest -verbose`
How do I use options when running pytest with python from the CLI?从 CLI 运行 pytest 和 python 时,如何使用选项?
EDIT: The comment from Dinari solved it, I mistakenly used -verbose
instead of --verbose
编辑:来自 Dinari 的评论解决了它,我错误地使用了
-verbose
而不是--verbose
You should use:你应该使用:
python -m pytest --verbose instead
Notice the double dash instead of the single dash.注意双破折号而不是单破折号。
You use the single dash when using the short version usually -v,however, here you use —verbose as you are using the long version.通常在使用短版本时使用单破折号 -v,但是,在这里您使用 -verbose,因为您使用的是长版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.