問(wèn)題描述
你最喜歡的 Python 模擬庫(kù)是什么?
What is your single favorite mocking library for Python?
推薦答案
我只用過(guò)一個(gè),但是用 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 的介紹比我說(shuō)得好:
Michael's introduction says it better than I could:
已經(jīng)有幾個(gè) Python 模擬庫(kù)可用,為什么還要另外一個(gè)?
There are already several Python mocking libraries available, so why another one?
大多數(shù)模擬庫(kù)都遵循'記錄->重播"的嘲諷模式.我更喜歡'動(dòng)作->assertion' 模式,尤其是在使用 Python unittest 模塊時(shí),更具可讀性和直觀性.
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.
...
它還提供實(shí)用功能/對(duì)象來(lái)協(xié)助測(cè)試,尤其是猴子補(bǔ)丁.
It also provides utility functions / objects to assist with testing, particularly monkey patching.
這篇關(guān)于你最喜歡的 Python 模擬庫(kù)是什么?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!