小编Cod*_*bee的帖子

如何模拟对象方法返回值

我目前拥有的是:

def some_method():
    some_obj = some_other_method()
    # This is what I want to mock return value of:
    some_obj.some_obj_some_method()

@patch('some_package.some_other_method')
def test_some_stuff(some_other_method_patch):
    some_other_method_patch.return_value = SomeObject()
Run Code Online (Sandbox Code Playgroud)

我怎样才能将 some_obj.some_obj_some_method() 返回值设置为 False?

python unit-testing mocking pytest python-mock

5
推荐指数
1
解决办法
5670
查看次数

标签 统计

mocking ×1

pytest ×1

python ×1

python-mock ×1

unit-testing ×1