【发布时间】:2021-04-07 21:18:57
【问题描述】:
我想检查是否调用了本地函数(在测试本身上声明)。
例如:
def test_handle_action():
action = "test"
user = "uid"
room = "room"
content = "test"
data = {}
def test_this(user, room, content, data):
pass
handlers = {action: test_this}
with mock.patch("handlers.handlers", handlers):
with mock.patch(".test_this") as f:
handle_action(action, user, room, content, data)
f.assert_called_with()
如何在我的测试中模拟函数test_this 的路径?
.test_this 我得到了错误:
E ValueError: Empty module name
【问题讨论】:
标签: python pytest python-mock