summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test/testmock/testasync.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-07-08 08:22:33 (GMT)
committerGitHub <noreply@github.com>2023-07-08 08:22:33 (GMT)
commit6cd08a566f11ff6862ccf8637d01b179da46515a (patch)
tree2df3e0303226b4d6dad21a5f20217c61b08281ce /Lib/unittest/test/testmock/testasync.py
parent1931c2a438c50e6250725c84dff94fc760b9b951 (diff)
downloadcpython-6cd08a566f11ff6862ccf8637d01b179da46515a.zip
cpython-6cd08a566f11ff6862ccf8637d01b179da46515a.tar.gz
cpython-6cd08a566f11ff6862ccf8637d01b179da46515a.tar.bz2
[3.11] gh-106300: Improve `assertRaises(Exception)` usages in tests (GH-106302). (GH-106545)
(cherry picked from commit 6e6a4cd52332017b10c8d88fbbbfe015948093f4) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib/unittest/test/testmock/testasync.py')
-rw-r--r--Lib/unittest/test/testmock/testasync.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/unittest/test/testmock/testasync.py b/Lib/unittest/test/testmock/testasync.py
index df260ab..b7c5d6d 100644
--- a/Lib/unittest/test/testmock/testasync.py
+++ b/Lib/unittest/test/testmock/testasync.py
@@ -427,9 +427,10 @@ class AsyncArguments(IsolatedAsyncioTestCase):
self.assertEqual(output, 10)
async def test_add_side_effect_exception(self):
+ class CustomError(Exception): pass
async def addition(var): pass
- mock = AsyncMock(addition, side_effect=Exception('err'))
- with self.assertRaises(Exception):
+ mock = AsyncMock(addition, side_effect=CustomError('side-effect'))
+ with self.assertRaisesRegex(CustomError, 'side-effect'):
await mock(5)
async def test_add_side_effect_coroutine(self):