mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-106300: Improve assertRaises(Exception)
usages in tests (GH-106302)
This commit is contained in:
parent
80b9b3a517
commit
6e6a4cd523
7 changed files with 20 additions and 12 deletions
|
@ -459,9 +459,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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue