pythoncode-coveragecoverage.pypython-coverage

How to install python's coverage module and use it from commandline in Windows


I want o learn how to use python's coverage.py module to inspect the coverage pattern of my code. I tried reading about the tool from various sources and finally installed it on my windows 7 machine using 'pip' utility. After installation, the coverage module got installed in C:\Python27\Lib\site-packages.

Now, I was reading instructions on how to use it from this page : Author's Installation Notes. I followed the installation instructions as per given on this page. However, after I installed, I'm unsure of how to use the tool from commandline? According to author after pip install of the tool, one should be able to invoke the command

coverage --version 

and expect to see some output. However, when I run this command, I get command not found error. According to me this is expected behavior, since coverage is just another python module (i.e. has .py extension) and not a standalone executable. So, I don't know how it can be run in a standalone fashion.

Someone please provide exact details of installation of the tool. I just need help with installation. I'll learn the CMD usage from nedbatchelder.com's "Coverage command line usage" article.


Solution

  • When you installed coverage, you should have gotten files you can execute directly, installed into c:\Python27\Scripts. Make sure you configure your Windows environment so that that directory is on your path. Then you'll be able to use coverage as a command.

    If you need help completing the Python installation on Windows, here are some detailed instructions.