简体   繁体   中英

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?

stack the decorators!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM