-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
29 lines (22 loc) · 926 Bytes
/
conftest.py
File metadata and controls
29 lines (22 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import allure
from pytest import Item
"""
借鉴/学习上海-悠悠大佬的方案
blog地址: https://www.cnblogs.com/yoyoketang/tag/python%2Bplaywright/
"""
# 本地插件注册
pytest_plugins = ['plugins.pytest_playwright', 'plugins.pytest_base_url'] # noqa
def pytest_addoption(parser):
parser.addoption("--casepath", action="store")
def pytest_generate_tests(metafunc):
if 'case_path' in metafunc.fixturenames:
case_path = metafunc.config.getoption('casepath')
if case_path:
metafunc.parametrize("case_path", [case_path])
def pytest_runtest_call(item: Item): # noqa
# 动态添加测试类的 allure.feature()
if item.parent._obj.__doc__: # noqa
allure.dynamic.feature(item.parent._obj.__doc__)
# 动态添加测试用例的title 标题 allure.title()
if item.function.__doc__: # noqa
allure.dynamic.title(item.function.__doc__) # noqa