深圳网站搭建找谁,怎么在手机上制作app,100简单大气的科技公司名字,建立网站编程我试图做一个单元测试来检查这个python函数(dispatch)是否传递了正确的参数来处理\u结果。在在dispatch中调用处理“unu result”的函数时#xff0c;有没有方法“劫持”输入参数#xff1f;我没有在调度函数中修改代码的权限。在以下是单元测试中的want预览#xff1a;impo…我试图做一个单元测试来检查这个python函数(dispatch)是否传递了正确的参数来处理\u结果。在在dispatch中调用处理“unu result”的函数时有没有方法“劫持”输入参数我没有在调度函数中修改代码的权限。在以下是单元测试中的want预览import makerfrom operators import op_morphimport unittestfrom unittest.mock import Mockimport cv2img cv2.imread(/img_tests/unitTestBaseImage.png)def my_side_effect(*args, **kwargs):global imgprint(args)print(kwargs)if args!None:if len(args)0:if args[0] img:return 0return 3else:return 2return 1class TestCalls(unittest.TestCase):def test_dispatch(self):global imgmakerMock Mock()makerMock.deal_with_result.side_effect my_side_effect#calling the dispatch functionmaker.dispatch([json_example.json])#instead of passing this mock I want to get the real parameters passed#when the function deal_with_result is called in dispatch.tempmakerMock.deal_with_result(img)print(image return code: str(temp))if __name__ __main__:unittest.main(exitFalse)谢谢。在