0
点赞
收藏
分享

微信扫一扫

Pytest动态为用例添加mark标记


可以通过为用例函数添加pytestmarker属性为用例动态添加mark标记,示例如下

import pytest
import warnings
warnings.filterwarnings('ignore')


def test_b():
pass


def test_a():
pass

# 为用例test_a添加一个kkk标记
test_a.pytestmark = [
pytest.Mark(name='kkk',args=(), kwargs={})
]

命令行运行

python3 -m pytest -v -m kkk

运行结果中可以看到只运行了test_a用例



举报

相关推荐

0 条评论