Really what you're looking for is a Java-like environment where every
function call declares what exception types it might throw. Then you
could insist that each function call actually be observed throwing that
exception. Unfortunately for us tool-makers (but fortunately for the
rest of the world using Python), Python doesn't require functions to
declare exceptions that way.
Coverage measurement fundamentally needs two phases: 1) observe
interesting events in a running program, and 2) determine where those
events could have occurred but didn't. I know how to measure exceptions
being thrown (phase 1). I don't know how to do phase 2. If you have
some ideas, I'd love to hear them, and maybe we can get something built.
--Ned.
I was recently wishing for this, in part to understand control flow
and in part to improve performance.
Regards,
Zooko