Demonstrate that plain unittest does not support async tests (#7607)
Co-authored-by: Ran Benita <ran@unusedvar.com>
This commit is contained in:
parent
2bd0d97fcc
commit
44cd8a3a86
|
@ -0,0 +1,6 @@
|
|||
import unittest
|
||||
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
async def test_foo(self):
|
||||
assert False
|
|
@ -1241,3 +1241,18 @@ def test_asynctest_support(testdir):
|
|||
testdir.copy_example("unittest/test_unittest_asynctest.py")
|
||||
reprec = testdir.inline_run()
|
||||
reprec.assertoutcome(failed=1, passed=2)
|
||||
|
||||
|
||||
def test_plain_unittest_does_not_support_async(testdir):
|
||||
"""Async functions in plain unittest.TestCase subclasses are not supported without plugins.
|
||||
|
||||
This test exists here to avoid introducing this support by accident, leading users
|
||||
to expect that it works, rather than doing so intentionally as a feature.
|
||||
|
||||
See https://github.com/pytest-dev/pytest-asyncio/issues/180 for more context.
|
||||
"""
|
||||
testdir.copy_example("unittest/test_unittest_plain_async.py")
|
||||
result = testdir.runpytest_subprocess()
|
||||
result.stdout.fnmatch_lines(
|
||||
["*RuntimeWarning: coroutine * was never awaited", "*1 passed*"]
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue