【发布时间】:2020-02-27 23:09:03
【问题描述】:
我想为 API 编写一个测试套件。我的项目树看起来像: project tree
我需要一个“客户端”文件,其中包含我们初始化所有辅助函数的类(例如,使用参数、断言、配置等发送的实际请求)。和实际的测试类。所以我有
class Client()
__init__()
def helper_function()
class TestBackend(Client)
__init__()
def test_something()
然后我尝试使用 pytest 运行我的测试。我不断得到
PytestWarning:无法收集测试类“TestBackend”,因为它有 init 构造函数。
正如py.test skips test class if constructor is defined 所述,这是预期的行为。 SO链接到这个documentation 但是,出于对所有神圣事物的热爱,我无法找到解决我遇到的问题的方法,而且我认为这不是经常需要的案例。
【问题讨论】:
标签: python python-3.x automation pytest qa