Coverage.py 4.1b2: re-written branch measurement

3 views
Skip to first unread message

Ned Batchelder

unread,
Jan 24, 2016, 1:46:17 PM1/24/16
to coveragep...@googlegroups.com

I've just released Coverage.py 4.1b2:
https://pypi.python.org/pypi/coverage/4.1b2

This version includes a completely rewritten branch analysis
implementation. In 4.0 and before, the possible branches were
determined by examining the bytecode. Now, we use the AST. This has
resulted in a much more predictable assessment of possible branches,
closing a handful of long-standing bugs.

But it also means that some things that were not considered possible
branches now are. And in particular, they may be flagged as missing
branches. If you use branch coverage, I would be interested in your
feedback. There are some cases where it is not clear what the right
behavior is.

For example:

try: # 1
... # 2
except ValueError: # 3
... # 4
finally: # 5
... # 6

try: # 8
... # 9
except: # 10
... # 11
finally: # 12
... # 13

In the first block of code, there's a branch from line 3 to line 6, in
the case of an exception other than ValueError. Should coverage.py flag
that as missing if such an exception never happens? Right now it does.
In the second block of code, coverage.py understands that line 10 can
never jump to 13, because there is no exception that would skip line 11.

Try it, let me know what you think:
https://pypi.python.org/pypi/coverage/4.1b2

--Ned.



Reply all
Reply to author
Forward
0 new messages