Support '# pragma: no branch' in multi-line if statements (fix #754) by devdanzin · Pull Request #1773 · nedbat/coveragepy (original) (raw)

PythonParser.lines_matching() records a set of lines matching a given regex. However, it doesn't take multi-line statements into account. That causes statements that should be marked as "# pragma: no branch" to be counted as partial branches. IOW, "a pragma comment on the continuation lines of a multi-line if-statement won't have an effect".

This PR fixes that by mapping line numbers through parser._multiline, so that the number of the first line in a multi-line statement gets recorded instead.

Fixes #754.