Reputation: 2560
I want to write a test in order to check that a specific function was not called. Below is a pseudo example of my code:
Code
TestFunctionA():
if a > b:
TestFunctionB()
In order to check if it is called i do the following which is working
with mock.patch('TestFunctionB') as mock_TestFunctionB:
TestFunctionA()
mock_TestFunctionB.assert_called_once_with()
If i want to check if the function TestFunctionB was not called i tried the following but is not working
with mock.patch('TestFunctionB') as mock_TestFunctionB:
TestFunctionA()
assert not mock_TestFunctionB.assert_called_once_with()
Upvotes: 1
Views: 760
Reputation: 599638
There's a method specifically for that.
mock_TestFunctionB.assert_not_called()
Upvotes: 2