Pytest unittest-style 设置:模块设置

Pytest unittest-style setup: module setup

Pytest documentation 描述了 setup/teardown 事物的四种方法:

但是在一个项目中是这样实现的:

class TestClass:
    def setup(self):
        ...
    def test_1(self):
        ...
    ...

setup 方法在每次方法调用时都会被调用,就像文档中的 setup_method 一样(除了它不t 将 method 作为参数)。但我没有在文档或其他任何地方看到它。为什么有效?

检查此代码 https://pytest.org/latest/_modules/_pytest/python.html

我猜是继承和使用

def setup(self):