你最喜欢的Python模拟库是什么?

2024-03-29 09:18:59 发布

您现在位置:Python中文网/ 问答频道 /正文

你最喜欢的Python模拟库是什么?


3条回答

Mox,来自Google

来自古斯塔沃·尼梅耶的Mocker

它不是完美的,但它非常强大和灵活。

我只使用过一个,但是我用Michael Foord的Mock:http://www.voidspace.org.uk/python/mock/得到了很好的结果。

迈克尔的介绍比我说得好:

There are already several Python mocking libraries available, so why another one?

Most mocking libraries follow the 'record -> replay' pattern of mocking. I prefer the 'action -> assertion' pattern, which is more readable and intuitive particularly when working with the Python unittest module.

...

It also provides utility functions / objects to assist with testing, particularly monkey patching.

相关问题 更多 >