【发布时间】:2021-03-13 14:33:11
【问题描述】:
我正在使用 pytest 调用以下代码。
@pytest.fixture(scope='class')
def driver_init(request):
ch_driver = webdriver.Chrome(executable_path=Data.Ch_exe_path)
request.cls.driver = ch_driver
yield
ch_driver.close()
@pytest.mark.usefixtures("driver_init")
我收到一条错误消息
未找到夹具“driver_init”。可用的固定装置:缓存、capfd、capfdbinary、caplog、capsys、capsysbinary、doctest_namespace、extra、metadata、monkeypatch、pytestcon 图,record_property,record_testsuite_property,record_xml_attribute,recwarn,testrun_uid,tmp_path,tmp_path_factory,tmpdir,tmpdir_factory , worker_id。
【问题讨论】:
-
我觉得没问题 - 你能在装饰器之后显示测试类吗?是否有更多代码使用该夹具?
标签: python python-3.x pytest