#使用usefixtures和在测试方法中添加fixture参数差不多,但是只有后者才能用使用fix的返回值 @pytest.fixture() def some_data(): return (1,"a",None,{"b": 2}) def test_A(some_data): assert some_data[0]==1 def test_B(some_data): assert some_data[1]=="a" def test_C(some_data): assert some_data[2] is None def test_D(some_data): assert some_data[3]["b"]==2 #不能使用这种写法传值,会报错 @pytest.mark.userfixtures("some_data") def test_E(): assert some_data[0] == 1