Python mockito
允许您在使用某些参数调用时存根方法。
E.g。
from mockito import when
# No wonder that modules have to be imported first
import os.path
# Stub calls
when(os.path).exists("/some/dir").thenReturn(True)
when(os.path).exists("\some]dir").thenRaise(AssertionError("Invalid directory name"))
# Use stubs
assert os.path.exists("/some/dir")
assert os.path.exists("\some]dir") # raises AssertionError: Invalid directory name
https://code.google.com/p/mockito-python/wiki/Stubbing#Modules
与python mock
库有什么相同之处?