ylvi-bux
ylvi-bux

Reputation: 37

how to mock two functions using unittests mock.patch

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?

Upvotes: 2

Views: 173

Answers (1)

ti7
ti7

Reputation: 18920

stack the decorators!

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

Upvotes: 1

Related Questions