在boto3中,我如何使用Stubbermockdownload_fileobj这是一个资源方法?
例如:
import boto3
from botocore.stub import Stubber
s3 = boto3.resource('s3')
def foo(s3):
with open('filename', 'wb') as data:
s3.download_fileobj('mybucket', 'mykey', data)
def test_foo():
s3_test = boto3.resource('s3')
s3_stub = Stubber(s3_test.meta.client)
s3_stub.add_response() # something here
with s3_stub:
foo(s3_test)
千巷猫影
相关分类