import pytest
@pytest.fixture(scope="session")
def login():
print("\n輸入用戶名密碼登陸! configtest")
yield
print("退出登陸")
def test_cart(login):
print('用例1,登陸后執行添加購物車功能操作')
def test_search():
print('用例2,不登陸查詢功能操作')
def test_pay(login):
print('用例3,登陸后執行支付功能操作
pytest_fixture.py::test_cart
輸入用戶名密碼登陸! configtest
PASSED [ 33%]用例1,登陸后執行添加購物車功能操作
pytest_fixture.py::test_search PASSED [ 66%]用例2,不登陸查詢功能操作
pytest_fixture.py::test_pay PASSED [100%]用例3,登陸后執行支付功能操作
退出登陸