How to let MagicMock behave like a dict?

前端 未结 2 1476
情话喂你
情话喂你 2021-02-18 17:36

mock(http://mock.readthedocs.org/en/latest/index.html) is a great tool in python for unit test. It can conveniently mock a method or class or dict.But I encountered a problem wh

2条回答
  •  醉话见心
    2021-02-18 18:02

    You can always just create some silly class to do the same thing.

    In [94]: class MockResponses(dict):
       ....:     def redundantErrorResponses(self):
       ....:         return {}
    

提交回复
热议问题