Why do nosetests say coated is not an option?

I use nosetests to automatically detect and run my unittests. I would also like it to generate coverage reports.

When I run nosetests with the following command, everything works just fine

nosetests . 

I searched online to generate coverage, nosetests has a --with-coverage command line argument. I also double checked that this command exists with nosetests --help . However, whenever I run the following command, I get the following output

 nosetests --with-coverage . Usage: nosetests [options] nosetests: error: no such option: --with-coverage 

I double checked that the plugin plugin is installed by running

 nosetests --plugins 

appears on the list along with a bunch of other plugins.

I also know that I have coverage set because I can manually start collecting coverage data using something in the following lines:

 coverage run test.py 

Am I using the --with-coverage option incorrectly? Or is there something else I'm missing?

Thanks in advance.

+6
source share
3 answers

Your syntax is correct. This might be a problem with your environment, double check your python environment and where you have nose and coverage installed. As a health check, you can quickly configure the new virtualenv, install the nose and run the command with the coverage option.

+3
source

I have never had command line options. I did what Janne Karila suggested and created the setup.cfg file in the main directory of my projects. Once I had this file, I could just run nosetests with no arguments, and everything would work.

One of the problems that occurred while trying to create my document was that I could not understand what parameters were allowed in the configuration. But it turns out that you can use any of the commands here https://nose.readthedocs.org/en/latest/usage.html#options . Just leave a double dash in front of the command.

For reference, my current configuration file

 [nosetests] verbosity=1 detailed-errors=1 with-coverage=1 cover-erase=1 cover-package=application cover-html=1 cover-html-dir=htmlcov where=tests 

This configuration file talks about using coverage to erase the previous launch scope, only report files in the application package and output the html report to the htmlcov directory.

Hope this helps someone else in the future.

+2
source

As of nose 1.3.7 - the latest version available on Pypy - this command does not exist:

https://github.com/nose-devs/nose/blob/release_1.3.7/nose/plugins/cover.py

It seems that the documentation is created from the master branch of the project, for which it has :

https://github.com/nose-devs/nose/blob/master/nose/plugins/cover.py

What you can do is install nose from the main branch, like this:

pip install git+https://github.com/nose-devs/ nose@master --upgrade

He will say that he just installed 1.3.7 , but this is only because the version has not yet been removed in the setup.py project setup.py : https://github.com/nose-devs/nose/blob/master/setup. py # L4

Remember that you just installed an unreleased version of nose , there may be other errors.

+2
source

All Articles