Python unittest assert expection as a parameter
Python unittest assert expection as a parameter Question: How to assert called function which gets exception as a parameter? In my code: def mainFunc: # … raise ValueError(‘valueError’) # … except Exception as e: myFunc(e) In the test: from unittest.mock import patch # … @patch(‘main.myFunc’) def test(mock): mainFunc() mock.assert_called_with(ValueError(‘valueError’)) And I got: AssertionError: expected call …