pytest - fixture --- automatic application

pytest Import 
@ pytest.fixture (autouse = True) ----- plus auto = True, each method are performed before the automatic landing
DEF login_r (open_browser):
Print ( 'login')

@ pytest.fixture ()
DEF open_browser ():
Print ( 'open your browser')

DEF test_soso ():
Print ( 'Case3')

# @ pytest.mark.usefixtures ( 'lgoin_r')
DEF test_cart ():
Print ( 'Case 4')

IF __name__ == ' __main__ ':
pytest.main ()

Open a browser
landing
PASSED [50%] case3

pytest_twofixture.py::test_cart open the browser
landing
PASSED [100%] case4

Guess you like

Origin www.cnblogs.com/QaStudy/p/11565303.html