Skip to content

Commit f76ac4c

Browse files
authored
Merge pull request #7437 from bluetech/flaky-coroutine-never-awaited
testing: fix flaky tests due to "coroutine never awaited" warnings
2 parents eced536 + c8cfff6 commit f76ac4c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

testing/acceptance_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,14 +1160,19 @@ def test_usage_error_code(testdir):
11601160

11611161
@pytest.mark.filterwarnings("default")
11621162
def test_warn_on_async_function(testdir):
1163+
# In the below we .close() the coroutine only to avoid
1164+
# "RuntimeWarning: coroutine 'test_2' was never awaited"
1165+
# which messes with other tests.
11631166
testdir.makepyfile(
11641167
test_async="""
11651168
async def test_1():
11661169
pass
11671170
async def test_2():
11681171
pass
11691172
def test_3():
1170-
return test_2()
1173+
coro = test_2()
1174+
coro.close()
1175+
return coro
11711176
"""
11721177
)
11731178
result = testdir.runpytest()

0 commit comments

Comments
 (0)