I am trying to understand running coverage for python scripts. I am not able to understand a scenario where i try to run coverage for a simple script which has an infinite loop:
#!/usr/bin/python
print "The only statement!!!"
while True:
pass
After invoking coverage for this script, I will kill this process, since it is an infinite loop and if i try to get the result I am getting like:
- coverage run sample.py
- kill sample
- coverage report -m
Name Stmts Miss Cover Missing
-------------------------------------
I am not getting any coverage report. Am i doing some thing which is fundamentally wrong?
coverageneeds to be able to write its data out at program end, and if it can't handle the exit signal then it will not generate a report.So it depends how you are killing your process and how
coveragehandles the signal - works fine for me when using Ctrl+C (i.e. sending SIGINT) to interruptsample.pyIf you are using the
killutility with no options then you are sending SIGTERM by default, trykill -INT <pid>instead.