pytest fixture parametric

@ pytest.fixture a parameter params, accepts a list, the list can be used as input data for each use case. Data will say how many, how many use cases will form. 
As the following examples, used to form Example 3
test_parametrizing.py
 1 import pytest
 2 
 3 seq=["case1","case2","case3"]
 4 
 5 
 6 @pytest.fixture(scope="module",params=seq)
 7 def params(request):
 8     return request.param
 9 
10 
11 
12 def test_params(params):
13     print(params)
14     assert "case" in params

Excuting an order:

Disintegrate pytest test_parametrizing.py

 

Results of the:

 

Guess you like

Origin www.cnblogs.com/moonpool/p/11351859.html