pytest(1) - 执行顺序

import pytest

def setup_module():
print("整个模块开始只执行一次")

def teardown_module():
print("整个模块结束只执行一次")

def setup_function():
print("不在类中的方法先执行")


def teardown_function():
print("不在类中的方法先执行")


def test_out():
print("不在类中")


class TestOne:
def setup_class(self):
print("类前执行")

def teardown_class(self):
print("类后执行")

def setup_method(self):
print("方法前执行")

def teardown_method(self):
print("方法后执行")

@pytest.mark.parametrize("a,b", [(1, 2), (2, 3), (3, 4)],
ids=["1", "2", "3"])
def test_one(self, a, b):
print(a + b)

posted @ 2020-12-09 23:49  无敌小韭菜  阅读(35)  评论(0编辑  收藏  举报