問題描述
你最喜歡的 Python 模擬庫是什么?
What is your single favorite mocking library for Python?
推薦答案
我只用過一個,但是用 Michael Foord 的 Mock 效果很好:http://www.voidspace.org.uk/python/mock/.
I've only used one, but I've had good results with Michael Foord's Mock: http://www.voidspace.org.uk/python/mock/.
Michael 的介紹比我說得好:
Michael's introduction says it better than I could:
已經有幾個 Python 模擬庫可用,為什么還要另外一個?
There are already several Python mocking libraries available, so why another one?
大多數模擬庫都遵循'記錄->重播"的嘲諷模式.我更喜歡'動作->assertion' 模式,尤其是在使用 Python unittest 模塊時,更具可讀性和直觀性.
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.
這篇關于你最喜歡的 Python 模擬庫是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!