Branch miss in a try except

Issue #615 wontfix
Former user created an issue

Not sure if this is a bug or expected behaviour, but here goes:

The branch report for

try:
    assert False
except AssertionError:
    print('except')
print('done')

is

Name     Stmts   Miss Branch BrPart  Cover
------------------------------------------
cov.py       5      0      0      0   100%

Should the except be considered some kind of branch? Here the coverage is 100%, but I was excepting a missing branch for a run where the body of the try jumps directly to the print('done')

Comments (2)

  1. Ned Batchelder repo owner

    We don't treat that as a missed branch, because it's impossible to know what lines in a try block might possibly raise the exception. Suppose you had 20 lines inside the try. Should that be considered 20 separate missed branches? It would be an impossible amount of noise.

  2. Log in to comment