summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unittest/testmock/testasync.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-07-07 21:25:24 (GMT)
committerGitHub <noreply@github.com>2023-07-07 21:25:24 (GMT)
commit2ade2fc148fb25a0306d5b14f705396d98c8b926 (patch)
tree95c51ef73e255186d4b60ff7c216709c6232f64f /Lib/test/test_unittest/testmock/testasync.py
parent7e883d76c0a17a7c97782384d8e2ec025eade91b (diff)
downloadcpython-2ade2fc148fb25a0306d5b14f705396d98c8b926.zip
cpython-2ade2fc148fb25a0306d5b14f705396d98c8b926.tar.gz
cpython-2ade2fc148fb25a0306d5b14f705396d98c8b926.tar.bz2
[3.12] gh-106300: Improve `assertRaises(Exception)` usages in tests (GH-106302) (GH-106534)
gh-106300: Improve `assertRaises(Exception)` usages in tests (GH-106302) (cherry picked from commit 6e6a4cd52332017b10c8d88fbbbfe015948093f4) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib/test/test_unittest/testmock/testasync.py')
-rw-r--r--Lib/test/test_unittest/testmock/testasync.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_unittest/testmock/testasync.py b/Lib/test/test_unittest/testmock/testasync.py
index 5f12f9f..edd9a5d 100644
--- a/Lib/test/test_unittest/testmock/testasync.py
+++ b/Lib/test/test_unittest/testmock/testasync.py
@@ -436,9 +436,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):