Closed chrisrossi closed 3 years ago
This looks like the same issue as #1175 (a final "pass" is traced incorrectly). Since 3.10 handles it correctly, I don't think it will be fixed in the older versions of Python, but I've written https://bugs.python.org/issue44672 to get a decision.
There is a very specific case that exposes a bug in branch coverage only for Python 3.9. Here is a testcase I've distilled down to be as simple as I can get it and still expose the error:
All elements seem to be required here: the coroutine, the context manager, the try/except nested inside a try/finally, and the return statement from inside the context manager.
Running coverage in Python 3.9:
Running coverage in Python 3.8:
Note that deindenting the
return
statement so that it is outside of the context manager causes coverage to reach 100% again, which in the actual use case this came up in is an acceptable work-around.