Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

pytest

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?

like image 471
Hello lad Avatar asked Oct 27 '14 14:10

Hello lad


3 Answers

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.

like image 136
sdonk Avatar answered Nov 12 '22 06:11

sdonk


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
like image 22
Samuel Phan Avatar answered Nov 12 '22 06:11

Samuel Phan


If the other answers here didn't work for you, you may have py.test installed somewhere else in your system. In my case, I ran into the issue described here inside a virtual environment, but it turned out that pytest was defaulting to my system installation (which did not have pytest-cov installed).

Deactivate your virtual environment or start a new shell and run the following to confirm:

pip3 freeze | grep pytest

(or pip freeze | grep pytest if you're running python2)

If you find it, try uninstalling it, then reactivate your virtual environment and try again.

like image 7
daveruinseverything Avatar answered Nov 12 '22 05:11

daveruinseverything