diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-04-02 22:41:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-02 22:41:38 (GMT) |
commit | a68f2f0578bbf812fa2264d0e0bb388340d6e230 (patch) | |
tree | 28e7b09fab40a1a44088ca682bef53dc0ee02171 /Lib/test | |
parent | 55966f3a0d5f1bf823bd22ce1abbde267b06552f (diff) | |
download | cpython-a68f2f0578bbf812fa2264d0e0bb388340d6e230.zip cpython-a68f2f0578bbf812fa2264d0e0bb388340d6e230.tar.gz cpython-a68f2f0578bbf812fa2264d0e0bb388340d6e230.tar.bz2 |
bpo-29922: Improve error messages in 'async with' (GH-6352)
when __aenter__() or __aexit__() return non-awaitable object.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_coroutines.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py index fe26199..9ad7ff9 100644 --- a/Lib/test/test_coroutines.py +++ b/Lib/test/test_coroutines.py @@ -1255,7 +1255,9 @@ class CoroutineTest(unittest.TestCase): pass with self.assertRaisesRegex( - TypeError, "object int can't be used in 'await' expression"): + TypeError, + "'async with' received an object from __aenter__ " + "that does not implement __await__: int"): # it's important that __aexit__ wasn't called run_async(foo()) @@ -1275,7 +1277,9 @@ class CoroutineTest(unittest.TestCase): run_async(foo()) except TypeError as exc: self.assertRegex( - exc.args[0], "object int can't be used in 'await' expression") + exc.args[0], + "'async with' received an object from __aexit__ " + "that does not implement __await__: int") self.assertTrue(exc.__context__ is not None) self.assertTrue(isinstance(exc.__context__, ZeroDivisionError)) else: @@ -1299,8 +1303,9 @@ class CoroutineTest(unittest.TestCase): with self.assertRaisesRegex( - TypeError, "object int can't be used in 'await' expression"): - + TypeError, + "'async with' received an object from __aexit__ " + "that does not implement __await__: int"): run_async(foo()) self.assertEqual(CNT, 1) |