import pytest @pytest.fixture(scope="function") def start(): print("\n 登录") def test_01(): print("执行01") @pytest.mark.usefixtures("start") def test_02(): print("执行02") def test_03(): print("执行03") def test_04(start): print("执行04")
-----------------------------------
import pytest @pytest.fixture() def start(): print("\n 登录") @pytest.fixture() def open_broswer(): print("\n 打开首页") @pytest.mark.usefixtures("start", "open_broswer") def test_01(): print("执行01") def test_02(start, open_broswer): print("执行02")