Skip to content

Commit

Permalink
shoehorn unittest async results into python test result interpretation
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Mar 29, 2020
1 parent cfac682 commit ec2cb0f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/_pytest/python.py
Expand Up @@ -192,10 +192,14 @@ def pytest_pyfunc_call(pyfuncitem: "Function"):
funcargs = pyfuncitem.funcargs
testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames}
result = testfunction(**testargs)
if (
hasattr(result, "__await__") or hasattr(result, "__aiter__")
) and not async_ok_in_stdlib:
async_warn(pyfuncitem.nodeid)
if hasattr(result, "__await__") or hasattr(result, "__aiter__"):
if async_ok_in_stdlib:
# todo: investigate moving this to the unittest plugin
# by a test call result hook
testcase = testfunction.__self__
testcase._callMaybeAsync(lambda: result)
else:
async_warn(pyfuncitem.nodeid)
return True


Expand Down

0 comments on commit ec2cb0f

Please sign in to comment.