Code Coverage support for unittest?

John Roth johnroth at ameritech.net
Fri Sep 21 00:15:09 CEST 2001


"Michael Chermside" <mcherm at destiny.com> wrote in message
news:mailman.1000914322.13649.python-list at python.org...
> I was reading this:
>
>
http://www.amk.ca/python/writing/mx-architecture/#SECTION0008000000000000000
00
>
> and the author referred to using a modified version of Skip Montanaro's
> trace.py to get CODE COVERAGE reporting for unit tests written using the
> unittest module.
>
> Really? How? I must have missed this in the docs! It sounds great...
> does anyone know the details, or where (if at all) it's documented?
>
> -- Michael Chermside
>

I did it a couple of months ago, and I don't remember the details,
except that it wasn't very hard. I just ran the unit test script under the
code coverage module. Granted, then it also did code coverage for
unittest, but I can live with that.

The first problem I had was that I couldn't unzip the thing under
Windows! Eventually, I got real creative with a combination of PKZip
and wordpad, and managed to get it out, but it wasn't pretty.

The second problem was (and is) that it isn't integrated into the
unit test framework. It needs a lot more work to be able to simply
run it and then get a simple "OK" (meaning 100% code coverage),
or a report on what wasn't covered.

In addition, there are a lot of holes in the actual coverage itself.
Some of these are in the analyzer / reporter, and could be fixed,
but some of them are in the structure of the debugging support
in Python, and would require changes to the debugger interface to
the interpreter to fix. This includes coverage tests of "short-circuit"
operators - there doesn't seem to be any way of telling
what parts of the expression were actually executed.

John Roth
>





More information about the Python-list mailing list