ternary ifs not taken into account by branch coverage

Issue #509 wontfix
Antony Lee created an issue

coverage 4.1, python 3.5.2, arch linux

test.py

cond = True

if cond:
    x = 1
else:
    x = 2

x = 1 if cond else 2
x = cond and 1 or 2

Getting branch coverage for this file shows partial coverage of the first if cond:, but not of the ternary (inline) if cond, or of the short-circuiting binary operators.

Comments (4)

  1. Ned Batchelder repo owner

    Bytecode tracing is definitely an enabling technology, but there is still a lot to be done, including how to correlate tokens in the source with bytecodes at run-time. There's no information in the compiled code object about that. If someone wants to do some experiments, I'll be very interested in the results.

  2. Log in to comment