更新时间:2023-10-21 21:41:58
可以通过模拟操作返回值来完成
Can be done by mock the action return value
class TestHandler(unittest.TestCase):
@mock.patch('__main__.Client.action')
def test_example_client_action_false(self, mock_client_action):
"""Test Example When Action is False"""
mock_client_action.return_value = False
handler = Handler()
self.assertFalse(handler.example())