问题
如何在 PyCharm 中传递多个 pytest 命令行选项?
问题描述
设置 pytest 的日志记录选项--log-level=DEBUG --log-cli=True --log-cli-level=DEBUG
时,在 PyCharm 运行配置中会出现错误。
Launching pytest with arguments --log-level=DEBUG --log-cli=True --log-cli-level=DEBUG ****/test_040_objective_sigmoid.py in ****
ERROR: usage: _jb_pytest_runner.py [options] [file_or_dir] [file_or_dir] [...]
_jb_pytest_runner.py: error: unrecognized arguments: --log-cli=True
inifile: None
rootdir: ****
只传入一个参数时,它可以正常运行而不报错。
Launching pytest with arguments --log-level=DEBUG ****test_040_objective_sigmoid.py in ****
============================= test session starts ==============================
platform linux -- Python 3.8.5, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 -- ****/bin/python
cachedir: .pytest_cache
rootdir: ****
plugins: pytest_check-1.0.1
collecting ... collected 5 items
在命令行下运行pytest时,pytest日志选项有效。
$ pytest --log-level=DEBUG --log-cli=True --log-cli-level=DEBUG --verbose --cache-clear -x ${DIR}
===============================================================================================
test session starts
===============================================================================================
platform linux -- Python 3.8.5, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
...
< p > 在PyCharm中设置pytest
参考资料