我有一个模块:
Interest
- __init__.py
- simple
- compound
__init__.py:
def add (x, y):
return x + y
我想使用 mock 测试我的模块。为此,我想模拟里面定义的函数
__ init __.py 并返回模拟值。
那么该怎么做呢?
最佳答案
您可以直接从 __init__.py
所在的模块模拟它。
@patch('Interest.add')
关于python - 如何模拟 __init__.py 中定义的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38006236/