简体   繁体   English

无法使用 python 安慰剂捕获 boto3

[英]can't capture boto3 using python placebo

I have some Python (v.3.x) that works like a charm on AWS using boto3 etc.. Now I'm asked to write some tests around that, so I found this to capture the response which I'll create the test around it:我有一些 Python (v.3.x),它在 AWS 上使用 boto3 等很有魅力。现在我被要求围绕它编写一些测试,所以我发现它可以捕获我将创建测试的响应周围:

https://github.com/garnaat/placebo https://github.com/garnaat/placebo

Using ptpython I'm able to run my code, but the recording is not happening (not that I can find), here's what I did:使用 ptpython 我能够运行我的代码,但没有进行录音(不是我能找到的),这是我所做的:

session = boto3.Session()
pill = placebo.attach(session, data_path='/c/Users/myuser/placebo')
pill.record()
run my python code which does the job

The only thing I'm thinking right now is the fact I'm on Windows 7, maybe it's not accepting the path.我现在唯一在想的是我在 Windows 7 上的事实,也许它不接受路径。
Any thoughts?有什么想法吗?

I solved the issue, this step is not included in the documentation above I found it elsewhere:我解决了这个问题,这一步没有包含在上面的文档中,我在别处找到了它:

session = boto3.Session()
pill = placebo.attach(session, data_path='.')
pill.record()
ec2 = session.client('ec2', region_name='us-west-2')
response = ec2.describe_instances()

that got me a recording, from here I can do whatever boto3 code I want - hope this helps anyone.这给了我一个录音,从这里我可以做任何我想做的 boto3 代码 - 希望这对任何人都有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM