Skip to content

Commit ad652eb

Browse files
committed
warn for async gen functions
1 parent 7534020 commit ad652eb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/_pytest/python.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ def pytest_configure(config):
152152
@hookimpl(trylast=True)
153153
def pytest_pyfunc_call(pyfuncitem):
154154
testfunction = pyfuncitem.obj
155-
if iscoroutinefunction(testfunction):
155+
if iscoroutinefunction(testfunction) or (
156+
sys.version_info >= (3, 6) and inspect.isasyncgenfunction(testfunction)
157+
):
156158
msg = "async def functions are not natively supported and have been skipped.\n"
157159
msg += "You need to install a suitable plugin for your async framework, for example:\n"
158160
msg += " - pytest-asyncio\n"

testing/acceptance_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,11 +1227,11 @@ async def test_2():
12271227
[
12281228
"test_async.py::test_1",
12291229
"test_async.py::test_2",
1230-
"*Coroutine functions are not natively supported*",
1230+
"*async def functions are not natively supported*",
12311231
"*2 skipped, 2 warnings in*",
12321232
]
12331233
)
12341234
# ensure our warning message appears only once
12351235
assert (
1236-
result.stdout.str().count("Coroutine functions are not natively supported") == 1
1236+
result.stdout.str().count("async def functions are not natively supported") == 1
12371237
)

0 commit comments

Comments
 (0)