07-pytest-fixture实现teardown

目录

代码示例


代码示例

# -*- coding: utf-8 -*-
# @Time    : 2021/10/10
# @Author  : 大海
import pytest


@pytest.fixture(autouse=True)
def start():
    print("登录")

    yield
    print("执行teardown!")
    print("登出")


def test_1():
    print("业务流程1")


def test_2():
    print("业务流程2")


def test_3():
    print("业务流程3")


if __name__ == "__main__":
    pytest.main(["-s", "test_11.py"])

猜你喜欢

转载自blog.csdn.net/IT_heima/article/details/120685783