py.test: error: unrecognized arguments: --cov=ner_brands --cov-report=term-missing --cov-config

匿名 (未验证) 提交于 2019-12-03 08:33:39

问题:

when I am trying to run my test through command line

py.test  file_name.py 

I got this error:

py.test: error: unrecognized arguments: --cov=ner_brands --cov-report=term-missing --cov-config 

How can I fix this?

回答1:

pytest-cov package is required if you want to pass --cov arguments to pytest, by default it should not be passed though. Are you using a modified version of py.test?

pip install pytest-cov 

would fix your issue.



回答2:

For those who use CentOS 6, the version of setuptools is old and you need to upgrade it also:

pip install pytest-cov pip install --upgrade setuptools 

Just after installing pip install pytest-cov:

~ # py.test --version This is pytest version 3.0.5, imported from /usr/lib/python2.6/site-packages/pytest.pyc  ~ # pip install --upgrade setuptools [...] Successfully installed setuptools-30.3.0  ~ # py.test --version This is pytest version 3.0.5, imported from /usr/lib/python2.6/site-packages/pytest.pyc setuptools registered plugins:   pytest-cov-2.4.0 at /usr/lib/python2.6/site-packages/pytest_cov/plugin.py 


回答3:

sdonk's answer helped me. But since I use pipenv, I had to run

pipenv install pytest_cov 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!