Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle decorators for AsyncFunctionDefs. Closes #964 #965

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions coverage/parser.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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