python-3.x - 如何在 python 中模拟 s3 对象?
问题描述
在我的代码中,有一种方法可以从 s3 存储桶中获取 csv 文件。我需要在我的测试文件中模拟该对象。下面是源函数
s3 = boto3.client('s3')
def method():
...
obj = s3.get_object(bucket, key)
csv_content = obj['Body'].read().decode('utf-8')
...
我需要模拟上面的'obj'。我需要使用单独的模块吗?请提出你的想法
解决方案
Moto 是 python 中用于模拟 S3 和其他一些 AWS 服务的常用包。
推荐阅读
- c# - C# GetWindowModuleFileName 和 GetWindowText 给出不同句柄的结果
- c# - Xamarin Forms:没有名称='getDrawable'签名='(I)Landroid/graphics/drawable/Drawable;'的方法 在 Landroid/content/Context 类中;
- tensorflow - 如何使用numpy对tensorflow lite中的张量进行操作
- python - 如何在 Python 中执行一次脚本
- php - mysql json在哪里
- python - 在python数组中查找和替换子数组
- c# - 安装时出错 - 自己开发的 Microsoft Office C# VSTO Addin
- dagger - Java android 编程 dagger.builder
- python - 当我试图删除一行时,SQLAlchemy 正在做额外的选择
- system-verilog - Systemverilog 关联数组方法