pytest_fixture--scope="session"


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,登陸后執行支付功能操作
退出登陸


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM