Lambda expression confuses branch measurement

Issue #90 resolved
Ned Batchelder
repo owner created an issue

A line like this:

    fn = make_sortable or (lambda x: x) 

is marked as being a branch with a missing jump to "exit", maybe only if the lambda isn't used.

Comments (9)

  1. Carl Meyer

    I can verify that, at least in my case, the missing jump to exit disappeared when I ensured the lambda was used during the test run. Seems to me this could be considered useful coverage information, not a bug -- if anything, the branch-coverage report should special-case this to display a more informative label on the line?

  2. Ned Batchelder reporter

    A particularly confusing form of this bug:

        lambda x: 2*x,

    The "OPERATIONS = " line will have a missed branch to "exit" if the lambda expression is never executed.

  3. Ned Batchelder reporter

    It's not as good as I would like, but as of now, the HTML shows "3 ↛ exit", and the hover text reads "line 6 didn't finish the lambda on line 6".

    I think this provides enough information to the reader. Getting more precise would require collecting data differently, to distinguish the line 6 execution during building the list, from line 6 execution during running the lambda. We can distinguish them based on the co_firstlineno of the frame, but we don't have a way to record that data as we go.

  4. Log in to comment