Top-rated recipes tagged "coverage"http://code.activestate.com/recipes/tags/coverage/top/2010-10-17T15:17:44-07:00ActiveState Code RecipesGenerating Code Coverage HTML Output (Python) 2010-10-17T15:17:44-07:00Sebastien Martinihttp://code.activestate.com/recipes/users/2637141/http://code.activestate.com/recipes/491274-generating-code-coverage-html-output/ <p style="color: grey"> Python recipe 491274 by <a href="/recipes/users/2637141/">Sebastien Martini</a> (<a href="/recipes/tags/coverage/">coverage</a>, <a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/html/">html</a>). Revision 11. </p> <p>Code coverage testing is very useful especially for dynamic languages, it can easily give a view of the unused parts of your code. Not that this method is able to prove that statements are dead code, but instead help to prevent from syntax errors and to force yourself to think about your code, to find the right test cases reaching the unused statements.</p> <p>In that sense, the module <a href="http://www.nedbatchelder.com/code/modules/coverage.py">coverage.py</a> made by <a href="http://www.nedbatchelder.com">Ned Batchelder</a> is very useful and efficient.</p> <p>The analysis returned by this module is very accurate, but as unreached lines numbers are not very readable by itself, this recipe simply generate an html output highlighting unreached lines. This recipe is directely based upon a <a href="http://chrisarndt.de/en/software/python/colorize.html">source code colorizer</a> derived from <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52298">this</a> recipe.</p>