【发布时间】:2014-03-13 02:36:54
【问题描述】:
我正在尝试为如下所示的类编写单元测试。
import boto
class ToBeTested:
def location(self, eb):
return eb.create_storage_location()
def some_method(self):
eb = boto.beanstalk.connect_to_region(region, access_key, secret_key)
location(eb)
有没有办法模拟 boto.beanstalk.connect_to_region 返回值并最终模拟 create_storage_location?我是 python 中修补和模拟的新手,所以我不知道我该怎么做。有人可以让我知道是否有办法做到这一点?
非常感谢!
【问题讨论】:
标签: python unit-testing mocking patch boto