mockredis:模拟如何工作(示例)

时间:2018-10-12 07:39:04

标签: python redis utest

我该如何模拟例如hgetall,hdel,hsetnx等。使用嘲讽的redis方法。我找到了描述如何修补redis实例的描述,但我不知道该怎么做才能模拟redis方法。例如,当我的测试方法调用hgetall时,我想返回我的测试结果,例如{“ testkey”:“ 1”}

from mockredis import mock_strict_redis_client

@patch('redis.StrictRedis', mock_strict_redis_client)
    def test_xxxx(self):

    call_my_function()

0 个答案:

没有答案
相关问题