how to mock two functions using unittests mock.patch

Viewed 47

I need to mock two functions inside my API post method. Mocking just one function worked well, but I have no idea how to do it when i need to mock two functions?

@unittest.mock.patch('path.to.first.function.thefirstfunction')
def test_connector_post(mock_thefirstfunction):
... 

Any ideas?

1 Answers

stack the decorators!

@unittest.mock.patch("functionA")
@unittest.mock.patch("functionB")
def test_foo(...):
    ... 
Related