pytest - fixture of parametric

Scene: The test case execution, and some use cases need to be logged in to perform, some patients do not need to use landing. setup and teardown can not be met. fixture can. The default scope (range) function

 

• Step:
1. Import pytest
2. In the above function plus @ pytest.fixture landing ()
3. Incoming (login function name) in the test method you want to use, on the first landing 4. not passed not landing direct the implementation of the test method

pytest Import 
@ pytest.fixture (the params = [l, 2,3, 'Linda']) ------ may be a tuple list may be
def prepara_data (request): ------ reuest is fixed wording
return request.param
------ reuest.param wording is fixed


def test_one(prepara_data):
print('testdata:%s'%prepara_data)

 

Guess you like

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