如何在通过pytes测试类测试时防止PytestCollectionWarning

2024-04-29 03:13:30 发布

您现在位置:Python中文网/ 问答频道 /正文

更新到更一般的情况: 在通过pytest测试类测试时,如何防止PytestCollectionWarning?简单示例遗嘱.py公司名称:

class Testament():
    def __init__(self, name):
        self.name = name

    def check(self):
        return True

还有测试_遗嘱.py

^{pr2}$

这会在与pytest一起运行时创建一个PytestCollectionWarning。是否有方法可以在不关闭所有警告的情况下抑制导入模块的此警告?


Tags: namepyself名称警告示例initpytest