怎么用装饰器@pytest.fixture等于setup teardown

img

     @pytest.mark.usefixtures(search_cloud”)
     @pytest.mark.parametrize(data,loc.ab_data)
十
     def test_ab(self,search_cloud,data):
         #Webab(search_cloud).cloud_login(usernamepwd
         Webabsearch_cloud).cloud_logindatausername”],data[pwd”])
         time.sleep(2)
         #assert check == WebCloudSearchsearch_cloud).clous_sousuC
人
         #assert datal check== WebCloudSearchsearch_cloud).clous_sousuO
一
一 assert dataL.check]== webCloudSearchsearch_cloud).clous_tuichuO
     @pytest.mark.usefixtures(search_cloud~)
     @pytest.mark.parametrize(data,loc.aa_data)
     def test_ac(self,search_cloud,data)
         Webab(search_cloud).cloud_aa(dataww”])
         time.sleep(2)
         assert dataL.“checki”] == WebCloudSearch(search_cloud).clous_scC

img

@pytest.fixture(scope=function)
def search_cloud():
         options=webdriver.ChromeOptions(
        options.add_argument(--ignore-certificate-errors’)
         driver=webdriver.Chrome(options=options)
         #driver=webdriver.ChromeC
        driver.get.(url_config.get.(excel_re,ur1))
         driver.maximize_window(
         time.sleep(2)
        yielddriver.fyield往上是前置条件,住下是后置条件。且yield也是个返回值跟return差不多
        driver.quit()
一

你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答


本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。


因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。