Python, mock: raise exception [closed]

I changed

@patch('stdLib.StdObject', autospec=True)

to

@patch('stdLib.StdObject', **{'return_value.raiseError.side_effect': Exception()})

and removed the # <--- do not work line.

It’s now working.

This is a good example.

EDIT:

mockedObj.raiseError.side_effect = Mock(side_effect=Exception('Test'))

also works.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)