python mock和magic mock有什么不同,因为我可以看到
>>> dir(Mock()) == dir(MagicMock())
True何时使用模拟对象&何时使用MagicMock对象??
发布于 2014-04-10 17:32:51
MagicMock is a subclass of Mock with default implementations of many magic methods. You can use MagicMock without having to configure the magic methods yourself.
我认为上面的代码会自动影响mock的大部分魔术方法。
检查这个指南,它可能会帮助你Magic Methods
和官方文档https://docs.python.org/2/reference/datamodel.html#special-method-names
https://stackoverflow.com/questions/22983926
复制相似问题