尝试使用Coverage模块为用Python编写的代码获取代码覆盖率。我使用Moto模拟BOTO3调用。
但是,为代码覆盖率而创建的html中没有涵盖模拟调用。
使用以下命令生成报告
coverage run handler.py
coverage html handler.py
为了使问题简短,我只粘贴了几行代码,以便能够像附加的图像一样覆盖,call()方法应该显示s3_client=boto3.client('s3')的覆盖率。测试代码如下:
@mock_s3
def test_handler_moves_incoming_object_to_processed():
client = boto3.client('s3')
test_handler_moves_incoming_object_to_processed()