Code Coverage and Unit Testing of Python Code

11,078

Solution 1

PyDev seems to allow code coverage from within Eclipse.

I've yet to find how to integrate that with my own (rather complex) build process, so I use Ned Batchelder's coverage.py at the command line.

Solution 2

We use this Django coverage integration, but instead of using the default coverage.py reporting, we generate some simple HTML: Colorize Python source using the built-in tokenizer.

Solution 3

There is also figleaf which I think is based on Ned Batchelder's coverage.py. We use nose as the driver for the testing. It all works pretty well. We write our unit tests using the built-in unittest and doctest modules.

Solution 4

NetBeans' new Python support has tightly integrated code coverage support - more info here.

Solution 5

If you want interactive code coverage, where you can see your coverage stats change in real time, take a look at Python Coverage Validator.

Share:
11,078

Related videos on Youtube

bhadra
Author by

bhadra

Updated on July 31, 2020

Comments

  • bhadra
    bhadra almost 4 years

    I have already visited Preferred Python unit-testing framework. I am not just looking at Python Unit Testing Framework, but also code coverage with respect to unit tests. So far I have only come across coverage.py. Is there any better option?

    An interesting option for me is to integrate cpython, unit testing of Python code and code coverage of Python code with Visual Studio 2008 through plugins (something similar to IronPython Studio). What can be done to achieve this? I look forward to suggestions.

    • yantrab
      yantrab over 15 years
      Maybe you could define "better". What do you want to do that coverage.py doesn't do? How do you need it to be better?
    • Kena
      Kena over 15 years
      I'd add that integration of coverage.py with IDEs (Eclipse, in my particular case) would be great.
  • Howard Sandford
    Howard Sandford over 15 years
    Orip, which branch of Testoob has the --coverage option? I've 1.13 release currently installed, but it doesn't seem to have that option there. Cheers H
  • Howard Sandford
    Howard Sandford over 15 years
    Ah, ignore that. Wasn't reading the docs correctly. For other interested parties, use the following syntax: testoob --coverage=normal test_file.py types of coverage are silent, slim, normal, massive, or xml
  • orip
    orip over 15 years
    @howard: glad you like it :) There's a new version with some coverage improvements coming out soon.
  • bhadra
    bhadra about 14 years