summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Braden <afflux@pentabarf.de>2020-03-24 19:31:57 +0100
committerKjell Braden <afflux@pentabarf.de>2020-03-24 20:13:08 +0100
commit0db15a2bd71e6893fadc91d262fa3fb2ead47ade (patch)
tree4ebdb83f1c70b6118480fe496854737bd3870b07
parentf318f932fadeda885077db678b06112a49bbea91 (diff)
downloadpython-coveragepy-git-0db15a2bd71e6893fadc91d262fa3fb2ead47ade.tar.gz
handle decorators for AsyncFunctionDefs. Closes #964
-rw-r--r--coverage/parser.py2
-rw-r--r--tests/test_arcs.py17
2 files changed, 19 insertions, 0 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index f0d378c6..70be0230 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -611,6 +611,8 @@ class AstArcAnalyzer(object):
_line__FunctionDef = _line_decorated
+ _line__AsyncFunctionDef = _line_decorated
+
def _line__List(self, node):
if node.elts:
return self.line_for_node(node.elts[0])
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index bf17f712..a02e9f7d 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -1557,6 +1557,23 @@ class AsyncTest(CoverageTest):
arcz_missing=".2 23 3.",
)
+ def test_async_decorator(self):
+ if env.PYBEHAVIOR.trace_decorated_def:
+ arcz = ".1 14 45 5. .2 2. -46 6-4"
+ else:
+ arcz = ".1 14 4. .2 2. -46 6-4"
+ self.check_coverage("""\
+ def wrap(f): # 1
+ return f
+
+ @wrap # 4
+ async def go():
+ return
+ """,
+ arcz=arcz,
+ arcz_missing='-46 6-4',
+ )
+
class ExcludeTest(CoverageTest):
"""Tests of exclusions to indicate known partial branches."""