I am using Jenkins to build and monitor the testing for my application.
I have such a piece of python code:
def register_os_handler():
def handler(signal, frm):
raise SystemExit()
signal(SIGHUP, handler)
In my test, I create a subprocess, and send it a SIGHUP signal and it quits as expected, which means it reaches the line of raise SystemExit().
When I submit it to Jenkins, all tests passed, but it says the line raise SystemExit() is not covered.
I feel curious that why that line was indeed reached, but still Jenkins complains?
How does the Jenkins' coverage report work?
If a process (even if it is a subprocess) quits, it cannot detect the line or take the line into account?
How to get around this?
I believe Jenkins uses coverage.py. If you want to compute coverage for subprocess, you need a little hack, which is described here:
http://nedbatchelder.com/code/coverage/subprocess.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With