小编Fra*_*anz的帖子

缺少测试覆盖率 pytest python 类

我正在使用 pytest --cov 测试我的代码,但我的一个模块的覆盖率是 0%。

该模块有一个类声明,如下所示:

class DataBaseMaker:
    @staticmethod
    def create_database():
        conn = sqlite3.connect("database.db")
        
    def __init__(self):
        self.foo = 'bar'
        
Run Code Online (Sandbox Code Playgroud)

该测试执行以下操作:

def test_create_database():
    DataBaseMaker.create_database()
    assert Path("database.db").is_file()
Run Code Online (Sandbox Code Playgroud)

测试覆盖率为 0% - 我在这里做错了什么?

python code-coverage pytest python-3.x pytest-cov

6
推荐指数
1
解决办法
3209
查看次数

标签 统计

code-coverage ×1

pytest ×1

pytest-cov ×1

python ×1

python-3.x ×1