Skip to content

Commit

Permalink
Merge pull request #965 from afflux/fix-964-asyncdef-line
Browse files Browse the repository at this point in the history
handle decorators for AsyncFunctionDefs. Closes #964
  • Loading branch information
nedbat committed Mar 26, 2020
2 parents f318f93 + 0db15a2 commit aaa9f42
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions coverage/parser.py
Expand Up @@ -611,6 +611,8 @@ def _line__Dict(self, node):

_line__FunctionDef = _line_decorated

_line__AsyncFunctionDef = _line_decorated

def _line__List(self, node):
if node.elts:
return self.line_for_node(node.elts[0])
Expand Down
17 changes: 17 additions & 0 deletions tests/test_arcs.py
Expand Up @@ -1557,6 +1557,23 @@ async def go():
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."""
Expand Down

0 comments on commit aaa9f42

Please sign in to comment.