[TIP] coverage - conditionally exclude code?

Albert-Jan Roskam fomcl at yahoo.com
Fri Jun 5 07:59:07 PDT 2015



Hello,

Is it possible to conditionally exclude bits of code from coverage measurements?
For example:
-under Python 2, can I exclude Python-3-only pieces of code?
-under Linux, can I exclude Windows-specific functions?


I have been looking here, but it does not appear to be possible:

http://nedbatchelder.com/code/coverage/excluding.html#excluding
The only way I can think of is by somehow dynamically adjusting the exclude_lines in .coveragerc


Great tool, by the way! The html reports really help enormously to discover untested pieces of code.

 
Regards,

Albert-Jan




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a 

fresh water system, and public health, what have the Romans ever done for us?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 



More information about the testing-in-python mailing list