mirror of
https://github.com/python/cpython.git
synced 2025-11-08 17:41:42 +00:00
[3.11] gh-106300: Improve assertRaises(Exception) usages in tests (GH-106302). (GH-106545)
(cherry picked from commit 6e6a4cd523)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
1931c2a438
commit
6cd08a566f
7 changed files with 20 additions and 12 deletions
|
|
@ -427,9 +427,10 @@ async def addition(self, var): pass
|
|||
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