请问我想用pytest写单元测试.不过如果我在每个测试中都需要用selenium开启页面.我有任何方法可以使每个测试共用base这个变量吗
谢谢
class TestLogin(object):
def setup_method(self, method):
self.driver = WebDriver(desired_capabilities=desired_capabilities, command_executor=command_executor)
self.current_method_name = method.__name__
def teardown_method(self, method):
self.driver.close()
self.driver.quit()
@pytest.fixture(scope="function")
def loadpage():
self.base = Home(self.driver).open()
def loadLogin():
base.loadLogin()
def test_a(self):
base = Home(self.driver).open()
assert True == base.dotesta()
base.loadLogin()
def test_b(self):
base = Home(self.driver).open()
assert True == base.dotestb()
base.loadLogin()
def test_c(self):
base = Home(self.driver).open()
assert True == base.dotestc()
base.loadLogin()