bpo-37100: Fix test_coroutines with -Werror (GH-13756) · python/cpython@3cf7ea1 (original) (raw)
`@@ -2250,7 +2250,8 @@ async def corofn():
`
2250
2250
`try:
`
2251
2251
`warnings._warn_unawaited_coroutine = lambda coro: 1/0
`
2252
2252
`with support.catch_unraisable_exception() as cm, \
`
2253
``
`-
support.captured_stderr() as stream:
`
``
2253
`+
support.check_warnings((r'coroutine .* was never awaited',
`
``
2254
`+
RuntimeWarning)):
`
2254
2255
`# only store repr() to avoid keeping the coroutine alive
`
2255
2256
`coro = corofn()
`
2256
2257
`coro_repr = repr(coro)
`
`@@ -2261,13 +2262,12 @@ async def corofn():
`
2261
2262
``
2262
2263
`self.assertEqual(repr(cm.unraisable.object), coro_repr)
`
2263
2264
`self.assertEqual(cm.unraisable.exc_type, ZeroDivisionError)
`
2264
``
`-
self.assertIn("was never awaited", stream.getvalue())
`
2265
2265
``
2266
2266
`del warnings._warn_unawaited_coroutine
`
2267
``
`-
with support.captured_stderr() as stream:
`
``
2267
`+
with support.check_warnings((r'coroutine .* was never awaited',
`
``
2268
`+
RuntimeWarning)):
`
2268
2269
`corofn()
`
2269
2270
`support.gc_collect()
`
2270
``
`-
self.assertIn("was never awaited", stream.getvalue())
`
2271
2271
``
2272
2272
`finally:
`
2273
2273
`warnings._warn_unawaited_coroutine = orig_wuc
`