--- a/src/eric7/DebugClients/Python/coverage/parser.py Sat Oct 01 17:30:55 2022 +0200 +++ b/src/eric7/DebugClients/Python/coverage/parser.py Sat Oct 01 17:37:10 2022 +0200 @@ -67,6 +67,9 @@ # The raw line numbers of excluded lines of code, as marked by pragmas. self.raw_excluded = set() + # The line numbers of class definitions. + self.raw_classdefs = set() + # The line numbers of docstring lines. self.raw_docstrings = set() @@ -130,6 +133,12 @@ indent += 1 elif toktype == token.DEDENT: indent -= 1 + elif toktype == token.NAME: + if ttext == 'class': + # Class definitions look like branches in the bytecode, so + # we need to exclude them. The simplest way is to note the + # lines with the 'class' keyword. + self.raw_classdefs.add(slineno) elif toktype == token.OP: if ttext == ':' and nesting == 0: should_exclude = (elineno in self.raw_excluded) or excluding_decorators @@ -292,6 +301,12 @@ continue exit_counts[l1] += 1 + # Class definitions have one extra exit, so remove one for each: + for l in self.raw_classdefs: + # Ensure key is there: class definitions can include excluded lines. + if l in exit_counts: + exit_counts[l] -= 1 + return exit_counts def missing_arc_description(self, start, end, executed_arcs=None): @@ -1287,7 +1302,6 @@ self.add_arc(start, -start, None, f"didn't finish the {noun} on line {start}") return _code_object__expression_callable - # pylint: disable=too-many-function-args _code_object__Lambda = _make_expression_code_method("lambda") _code_object__GeneratorExp = _make_expression_code_method("generator expression") _code_object__DictComp = _make_expression_code_method("dictionary comprehension")