简体   繁体   English

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

[英]Able to run Pytest from PyCharm but not through Command Line

I am trying this on Ubuntu. 我正在Ubuntu上尝试这个。 So when I run PyTest from PyCharm it worked perfectly but when I tried to run the same command I am getting different errors. 因此,当我从PyCharm运行PyTest时,它工作得很好,但是当我尝试运行相同的命令时,却遇到了不同的错误。 Surely I am not building my Command correctly. 当然,我没有正确构建命令。

So here is what it looks like in PyCharm 这就是PyCharm中的样子

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

And below are what I have tried on shell 下面是我在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'>

I have also tried this 我也尝试过

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 

So in this case it looks like its not able read my conftest file 因此,在这种情况下,它似乎无法读取我的conftest文件

yeah I think PyTest don't have a server argument. 是的,我认为PyTest没有服务器参数。 probably it`s missing some plugin 可能缺少一些插件

you can see the args list by typing 您可以通过键入以下内容来查看参数列表

py.test --help

check it out the plugin list https://pytest.org/dev/plugins_index/index.html that you can use. 请查看您可以使用的插件列表https://pytest.org/dev/plugins_index/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM