标签:sse import imp pre def Fix cas sed cart
import pytest
@pytest.fixture()
def login_r():
print(‘登陆‘)
@pytest.fixture()
def open_browser():
print(‘打开浏览器‘)
def test_soso():
print(‘case3‘)
@pytest.mark.usefixtures(‘login_r‘)----通过usefixtures可以让test_cart前置执行login
def test_cart():
print(‘case4‘)
if __name__ == ‘__main__‘:
pytest.main()
pytest_twofixture.py::test_soso PASSED [ 50%]case3
pytest_twofixture.py::test_cart 登陆
PASSED [100%]case4
案例2
import pytest
@pytest.fixture()
def login_r(open_browser):
print(‘登陆‘)
@pytest.fixture()
def open_browser():
print(‘打开浏览器‘)
def test_soso():
print(‘case3‘)
@pytest.mark.usefixtures(‘login_r‘)
def test_cart():
print(‘case4‘)
if __name__ == ‘__main__‘:
pytest.main()
pytest_twofixture.py::test_soso PASSED [ 50%]case3
pytest_twofixture.py::test_cart 打开浏览器
登陆
PASSED [100%]case4
标签:sse import imp pre def Fix cas sed cart
原文地址:https://www.cnblogs.com/QaStudy/p/11565337.html