branch coverage of with statement in 2.7 · Issue #128 · nedbat/coveragepy (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@nedbat

Description

@nedbat

Originally reported by Christian Heimes (Bitbucket: tiran, GitHub: tiran)


With Python 2.7, branch detection doesn't get a with statement right with an inner return right. Coverage show the line "with open("test", "w") as f" as a branch, that never reaches "exit". Under Python 2.6 the with statement is shown as fully covered.

#!python

def example(): 
    with open("test", "w") as f: # exit
        f.write("") 
        return 1 
 
example() 

Tested with coverage 3.4 and 3.5a1.