我想知道如何在另一个类中传递conftest(pytest)的self.driver?
conftest.py
def driver(request):
self.driver = webdriver.Remote("xxxxx")
def teardown():
self.driver.quit()
TestSample.py
Class B():
# How use self.driver ?????
答案 0 :(得分:1)
你可以玩夹具
conftest.py
def driver(request):
self.driver = webdriver.Remote("xxxxx")
def teardown():
self.driver.quit()
TestSample.py
@pytest.mark.usefixtures("driver")
Class B():
# How use self.driver ?????
def test_sample(self, driver):
tuto(driver)
答案 1 :(得分:-2)
使用()继承b()类,然后使用super()访问超类a()
的self.driver