【发布时间】:2023-01-03 22:03:07
【问题描述】:
我们可以对在 python 函数内的不同行调用的同一方法使用两个不同的猴子补丁脚本吗?
# abc.py
def add(a,b):
sum=a+b
return sum
# file1.py
def xyz():
...
sum = add(i,j)
...
...
addition = add(v,u)
...
...
# test_file1.py
def test_xyz():
..... # ---> I need to add two different monkey patch scripts for
# add() with different results within pytest
谁能帮我打猴子补丁?
【问题讨论】:
-
你能提供更多细节吗?如果只是添加,为什么还要打补丁?如果需要,请在伪代码中显示预期结果
标签: python unit-testing mocking pytest monkeypatching