diff options
-rw-r--r-- | CHANGES.rst | 9 | ||||
-rw-r--r-- | coverage/parser.py | 17 | ||||
-rw-r--r-- | tests/test_arcs.py | 8 |
3 files changed, 12 insertions, 22 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 70d48110..a0f62caa 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,8 +9,13 @@ Change history for Coverage.py Unreleased ---------- -- In beta 1, class docstrings were considered executable. Now they no longer - are. +- In 4.1 beta 1, class docstrings were considered executable. Now they no + longer are. + +- In 4.1 beta 1, ``yield from`` and ``await`` were considered returns from + functions, since they could tranfer control to the caller. This produced + unhelpful "missing branch" reports in a number of circumstances. Now they no + longer are considered returns. Version 4.1b1 --- 2016-01-10 diff --git a/coverage/parser.py b/coverage/parser.py index f0bfe614..07cb75d2 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -404,15 +404,6 @@ class AstArcAnalyzer(object): Return a set of line numbers, exits from this node to the next. """ - # Yield-froms and awaits can appear anywhere. - # TODO: this is probably over-doing it, and too expensive. Can we - # instrument the ast walking to see how many nodes we are revisiting? - if isinstance(node, ast.stmt): - for _, value in ast.iter_fields(node): - if isinstance(value, ast.expr) and self.contains_return_expression(value): - self.process_return_exits([self.line_for_node(node)]) - break - node_name = node.__class__.__name__ handler = getattr(self, "_handle__" + node_name, None) if handler is not None: @@ -759,14 +750,6 @@ class AstArcAnalyzer(object): self.arcs.add((-1, start)) self.arcs.add((start, -start)) - def contains_return_expression(self, node): - """Is there a yield-from or await in `node` someplace?""" - for child in ast.walk(node): - if child.__class__.__name__ in ["YieldFrom", "Await"]: - return True - - return False - class ByteParser(object): """Parse bytecode to understand the structure of code.""" diff --git a/tests/test_arcs.py b/tests/test_arcs.py index 5155264a..04dbd15a 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -977,7 +977,8 @@ class YieldTest(CoverageTest): list(gen([1,2,3])) """, - arcz=".1 19 9. .2 23 34 45 56 5. 63 37 7.", + arcz=".1 19 9. .2 23 34 45 56 63 37 7.", + arcz_unpredicted="5.", ) @@ -1195,8 +1196,9 @@ class AsyncTest(CoverageTest): """, arcz= ".1 13 38 8E EF FG G. " - ".4 45 56 5-3 6-3 " - ".9 9-8 9C C-8", + ".4 45 56 6-3 " + ".9 9C C-8", + arcz_unpredicted="5-3 9-8", ) self.assertEqual(self.stdout(), "Compute 1 + 2 ...\n1 + 2 = 3\n") |