代码之家  ›  专栏  ›  技术社区  ›  divyanayan awasthi

python中的coverage模块没有使用moto for boto3显示模拟对象的coverage

  •  0
  • divyanayan awasthi  · 技术社区  · 5 年前

    尝试使用Coverage模块为用Python编写的代码获取代码覆盖率。我使用Moto模拟BOTO3调用。

    但是,为代码覆盖率而创建的html中没有涵盖模拟调用。

    使用以下命令生成报告

    coverage run handler.py
    coverage  html handler.py
    

    enter image description here

    为了使问题简短,我只粘贴了几行代码,以便能够像附加的图像一样覆盖,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()
    
    0 回复  |  直到 5 年前