diff options
-rw-r--r-- | coverage/parser.py | 15 | ||||
-rw-r--r-- | lab/parser.py | 2 | ||||
-rw-r--r-- | tests/test_parser.py | 6 |
3 files changed, 3 insertions, 20 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index b47fd12e..d17d7c9b 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -67,9 +67,6 @@ class PythonParser: # 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() @@ -133,12 +130,6 @@ class PythonParser: 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 @@ -301,12 +292,6 @@ class PythonParser: 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): diff --git a/lab/parser.py b/lab/parser.py index 19cb94a8..50b43564 100644 --- a/lab/parser.py +++ b/lab/parser.py @@ -108,8 +108,6 @@ class ParserMain: marks[2] = str(exits) if lineno in pyparser.raw_docstrings: marks[3] = '"' - if lineno in pyparser.raw_classdefs: - marks[3] = 'C' if lineno in pyparser.raw_excluded: marks[4] = 'x' diff --git a/tests/test_parser.py b/tests/test_parser.py index 303f2b55..538e2500 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -43,7 +43,7 @@ class PythonParserTest(CoverageTest): pass """) assert parser.exit_counts() == { - 2:1, 3:1, 4:2, 5:1, 7:1, 9:1, 10:1 + 2:2, 3:1, 4:2, 5:1, 7:1, 9:2, 10:1 } def test_generator_exit_counts(self): @@ -89,7 +89,7 @@ class PythonParserTest(CoverageTest): pass """) assert parser.exit_counts() == { - 1:0, 2:1, 3:1 + 1:1, 2:1, 3:1 } def test_missing_branch_to_excluded_code(self): @@ -457,7 +457,7 @@ class ParserFileTest(CoverageTest): class Bar: pass """ - counts = { 2:1, 3:1, 4:2, 5:1, 7:1, 9:1, 10:1 } + counts = { 2:2, 3:1, 4:2, 5:1, 7:1, 9:2, 10:1 } name_endings = (("unix", "\n"), ("dos", "\r\n"), ("mac", "\r")) for fname, newline in name_endings: fname = fname + ".py" |