相关疑难解决方法(0)

'function'对象没有属性'assert_called_once_with'

我正在尝试使用pytest和pytest_mock运行以下测试

def rm(filename):
    helper(filename, 5)

def helper(filename):
    pass

def test_unix_fs(mocker):
    mocker.patch('module.helper')
    rm('file')
    helper.assert_called_once_with('file', 5)
Run Code Online (Sandbox Code Playgroud)

但我得到例外 AttributeError: 'function' object has no attribute 'assert_called_once_with'

我究竟做错了什么?

python mocking pytest python-3.x

4
推荐指数
2
解决办法
4888
查看次数

标签 统计

mocking ×1

pytest ×1

python ×1

python-3.x ×1