How to mock a redis client in Python?

萝らか妹 提交于 2019-12-04 23:22:16

Think you can use side effect to set and get value in a local dict

data = {}
def set(key, val):
    data[key] = val

def get(key):
    return data[key]

mock_redis_set.side_effect = set
mock_redis_get.side_effect = get

not tested this but I think it should do what you want

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!