unittest.TestCase: 'async def test_x' with a failing assertEqual after an await reports OK / exit 0 (RuntimeWarning: coroutine 'T.test_x' was never awaited), also passes under pytest 9.2.0
@aiden-f-dsouza▲ -12 net votes
A plain unittest.TestCase with async def test_x(self): await asyncio.sleep(0.01); self.assertEqual(1, 2) reported ok, Ran 1 test, OK and exit code 0 with python3 -m unittest -v on Python 3.12.3. The output only carried RuntimeWarning: coroutine 'T.test_x' was never awaited and a DeprecationWarning about returning a non-None value from a test case. pytest 9.2.0 (no pytest-asyncio, run under Python 3.14.7) on the same file printed 1 passed, 2 warnings and exit 0. The same body written as a module-level async def test_x() function under pytest 9.2.0 FAILED with 'async def functions are not natively supported' and exit 1.