summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-01-07 19:42:42 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-01-07 19:42:42 -0500
commit2e48dedf1ea439988fba0c9693cea7a818ab3213 (patch)
tree49fc7876f38354b55c7b144d42b784920160b0f8
parentfcc18ffcb11bca315c6c0690414e817d5c22b4dd (diff)
downloadpython-coveragepy-git-2e48dedf1ea439988fba0c9693cea7a818ab3213.tar.gz
Add tests of multiline lambdas, though i don't quite understand the line numbers involved
--HG-- branch : ast-branch
-rw-r--r--coverage/parser.py5
-rw-r--r--tests/test_arcs.py29
2 files changed, 30 insertions, 4 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index c03a3083..9f7400e5 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -312,8 +312,8 @@ class FunctionBlock(object):
class TryBlock(object):
def __init__(self, handler_start=None, final_start=None):
- self.handler_start = handler_start # TODO: is this used?
- self.final_start = final_start # TODO: is this used?
+ self.handler_start = handler_start
+ self.final_start = final_start
self.break_from = set()
self.continue_from = set()
self.return_from = set()
@@ -716,7 +716,6 @@ class AstArcAnalyzer(object):
start = self.line_for_node(node)
self.arcs.add((-1, start))
self.arcs.add((start, -start))
- # TODO: test multi-line lambdas
def contains_return_expression(self, node):
"""Is there a yield-from or await in `node` someplace?"""
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 28c1df72..c52bc8aa 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -1031,6 +1031,34 @@ class DecoractorArcTest(CoverageTest):
)
+class LambdaArcTest(CoverageTest):
+ """Tests of lambdas"""
+
+ def test_lambda(self):
+ self.check_coverage("""\
+ fn = (lambda x:
+ x + 2
+ )
+ assert fn(4) == 6
+ """,
+ arcz=".1 14 4-1 1-1",
+ )
+ self.check_coverage("""\
+
+ fn = \\
+ (
+ lambda
+ x:
+ x
+ +
+ 8
+ )
+ assert fn(10) == 18
+ """,
+ arcz=".2 2A A-4 2-4",
+ )
+
+
class AsyncTest(CoverageTest):
"""Tests of the new async and await keywords in Python 3.5"""
@@ -1108,7 +1136,6 @@ class AsyncTest(CoverageTest):
async with x:
pass
""",
- # TODO: we don't run any code, so many arcs are missing.
arcz=".1 1. .2 23 3.",
arcz_missing=".2 23 3.",
)