如何在测试(或方法)中自动使用 pytest fixture?

How to use a pytest fixture in a test (or method) automatically?

根据我找到的信息 here,我尝试了以下操作:

@pytest.mark.usefixtures("driver")
class TestSuite(object):
    def test1(self):
        driver.log("Start the test")

但是我得到一个错误

NameError: global name 'driver' is not defined

所以信息不正确,还是我理解错了?

如何在TestSuiteclass中的每个测试方法(或任何其他方法)中自动使用fixture?

更多信息:

usefixtures 表示列出的灯具将被自动调用,而不是它们在您的代码中可供您调用。

我怀疑是否有一种方法可以在不明确命名的情况下使用夹具。

class TestSuite(object):
    def test1(self, driver):
        driver.log("Start the test")

是唯一的方法。