Fix handling of multi-line function declarations by kajakaj · Pull Request #1705 · nedbat/coveragepy (original) (raw)

Resolves #684

The cause of this problem is the method of checking whether a particular clause should be excluded. In a file parser.py in function _raw_parse (line 161) only the line that ends with : is checked for excluded expressions, not all the lines in a statement that ends with a colon. The solution is to add checking if at least one line in the multi-line statement ended with : has to be excluded and if that is the case - to exclude that clause. Multi-line statements are added after a token \n, so after checking for excluded clauses in one-line statements. Because of that, checking if a clause after multi-line statement should be excluded was added starting from the line 193.
Tests with different use cases were added.