如何解决如何模拟在父函数 Python3 中多次调用的函数?
我有一个函数,它发出 3 个 get 请求以从 S3 存储桶中获取文件。所以我需要正确模拟它们以返回预期结果。下面是代码结构
# src.py
def parent(bucket,file):
json_object = get_object(bucket,file) ## will return a json file from s3.
csv_buck,csv_key = filter_key(json_object) # reading the content of json file and get the bucket name and key of another csv file located in another bucket
csv_obj = get_object(csv_buck,csv_key)
.... #do the other necessary stuffs
测试文件是
# test.py
class TestParent(TestCase):
def test_parent(self):
...
所以在实施测试之前,我需要知道是否可以将 get_object 模拟到 2 个不同的场景??
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。