summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/parser.py26
-rw-r--r--tests/test_arcs.py2
2 files changed, 18 insertions, 10 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index d599bef9..a5e12d35 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -264,16 +264,17 @@ class PythonParser(object):
return self._all_arcs
def arcs(self):
- aaa = AstArcAnalyzer(self.text)
- arcs = aaa.collect_arcs()
+ if self._all_arcs is None:
+ aaa = AstArcAnalyzer(self.text)
+ arcs = aaa.collect_arcs()
- arcs_ = set()
- for l1, l2 in arcs:
- fl1 = self.first_line(l1)
- fl2 = self.first_line(l2)
- if fl1 != fl2:
- arcs_.add((fl1, fl2))
- return arcs_
+ self._all_arcs = set()
+ for l1, l2 in arcs:
+ fl1 = self.first_line(l1)
+ fl2 = self.first_line(l2)
+ if fl1 != fl2:
+ self._all_arcs.add((fl1, fl2))
+ return self._all_arcs
def exit_counts(self):
"""Get a count of exits from that each line.
@@ -559,6 +560,13 @@ class AstArcAnalyzer(object):
# TODO: orelse
return exits
+ def handle_With(self, node):
+ start = self.line_for_node(node)
+ exits = self.add_body_arcs(node.body, from_line=start)
+ return exits
+
+ handle_AsyncWith = handle_With
+
def handle_default(self, node):
node_name = node.__class__.__name__
if node_name not in ["Assign", "Assert", "AugAssign", "Expr", "Import", "Pass", "Print"]:
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 08325f6b..3dc05c9c 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -912,7 +912,7 @@ class AsyncTest(CoverageTest):
x11 = 1
x12 = 1
""",
- arcz=".1 1. .2 23 2C 34 45 56 6B",
+ arcz=".1 1. .2 23 2C 34 45 48 54 56 6B 8B 9A AB B2 C.",
)
def test_async_with(self):