Skip to content

Covered branch inside finally block showing up as missing #623

Open
@nedbat

Description

@nedbat

Originally reported by David MacIver (Bitbucket: david_maciver_, GitHub: Unknown)


In some work I'm doing on Hypothesis, coverage is currently showing up some branches as missing that are covered.

Unfortunately I do not have a minimized reproduction. I tried a moderate amount and couldn't seem to trigger the behaviour in anything other than the actual example.

The following script will run a reproduction of this:

#!/usr/bin/env bash

git clone https://github.com/HypothesisWorks/hypothesis-python.git
cd hypothesis-python
git checkout [db1db2719cd09cfe5c565967667aca05bf8ad615 (bb)](https://bitbucket.org/ned/coveragepy/commits/db1db2719cd09cfe5c565967667aca05bf8ad615)
virtualenv v
source v/bin/activate
pip install coverage attrs pytest-xdist
export HYPOTHESIS_INTERNAL_COVERAGE=true
export PYTHONPATH=src
python -m coverage run  --branch --include=src/hypothesis/core.py -m pytest tests/cover/test_reproduce_failure.py  -n 0 --ff
coverage report --rcfile=/dev/null --show-missing

You will see a lot of things missing here because this isn't the full set of tests for that file, but the notable ones are "811->829, 824->829". Both of these are definitely covered - if you add an "else assert False" to the if branches then that assert will fire in these tests - but the report shows them as missing branches.

I've tested this on both Python 2.7.13 and 3.6.0 and it seems to behave the same way in each.

NB: You may notice that this file does a bunch of messing around with coverage and tracing. All of that should be turned off by the HYPOTHESIS_INTERNAL_COVERAGE=true environment variable, so I'm reasonably sure that's not the culprit here.


Metadata

Metadata

Assignees

No one assigned

    Labels

    branchbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions