能够从PyCharm运行Pytest但不能通过命令行运行

时间:2016-07-04 13:57:31

标签: python pycharm pytest

我在Ubuntu上尝试这个。因此,当我从PyCharm运行PyTest时,它工作得很好但是当我尝试运行相同的命令时,我得到了不同的错误。 当然,我没有正确构建我的命令。

所以这就是它在PyCharm中的样子

target = /some_path/test_xxx.py    
options= --server ### -s --browser firefox --html=report.html 

以下是我在shell上尝试的内容

lab-automation:~/My_Folder$ py.test /<some_path>/test_XXX.py --server ### -s --browser firefox --html=report.html 
Traceback (most recent call last):
  File "/usr/local/bin/py.test", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 48, in main
    config.pluginmanager.check_pending()
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 490, in check_pending
    (name, hookimpl.plugin))
_pytest.vendored_packages.pluggy.PluginValidationError: unknown hook 'pytest_html' in plugin <module 'pytest_suites.conftest' from '/<some_path>/conftest.pyc'>

我也试过这个

py.test --server ### -s --browser firefox --html=report.html /<some_path>/test_XXX.py
usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: --server --browser firefox 

所以在这种情况下看起来它无法读取我的conftest文件

1 个答案:

答案 0 :(得分:1)

是的,我认为PyTest没有服务器参数。 可能它缺少一些插件

您可以通过输入

来查看args列表
py.test --help

查看您可以使用的插件列表https://pytest.org/dev/plugins_index/index.html

相关问题