Let's say I have a function like that:
def foo():
bar()
Is there any way I could test if bar
is called, when I'm not passing bar as parameter? My team use Python 3.6 and 3.5
Let's say I have a function like that:
def foo():
bar()
Is there any way I could test if bar
is called, when I'm not passing bar as parameter? My team use Python 3.6 and 3.5
You should use patch for that:
@patch('path.to.bar')
def test_foo(self, mock_bar):
foo()
self.assertTrue(mock_bar.called)
You can also test with which values the function was called like this:
mock_bar.assert_called_with('some_param')
Hope it helps.