3

Pythonmockito允许您在使用某些参数调用时存根方法。

例如

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

pythonmock库的等价物是什么?

https://pypi.python.org/pypi/mock

4

0 回答 0