conftest.py 配置测试脚本

import pytest
from py.xml import html


@pytest.fixture()
def before():
    print("------->fixture标记的函数before")


@pytest.fixture(autouse=True)  # 设置为自动运行
def before2():
    print("------->fixture自启动,默认作用域为 function")


@pytest.fixture(autouse=True, scope='class')
def before3():
    print("------->fixture自启动,作用域class")


@pytest.fixture()
def need_data():
    return 2  # 返回数字2


@pytest.fixture(params=[1, 2, 3])
def need_data2(request):  # 传入参数request 系统封装参数
    return request.param  # 取列表中单个值,默认的取值方式


# 修改报告样式
# 修改Environment
def pytest_configure(config):
    # 修改Platform
    config._metadata["Platform"] = "Windows 11"
    # 添加接口地址与项目名称
    config._metadata["项目名称"] = "pytest"
    #config._metadata['接口地址'] = 'xxxxxx'
    # 删除Java_Home
    # config._metadata.pop("JAVA_HOME")


# 修改Summary
@pytest.mark.optionalhook
def pytest_html_results_summary(prefix):
    prefix.extend([html.p("所属部门: 测试")])
    prefix.extend([html.p("测试人员: Mr.Liu")])


@pytest.mark.optionalhook
def pytest_html_results_table_header(cells):
    cells.pop(-1)  # 删除link标题


@pytest.mark.optionalhook
def pytest_html_results_table_row(report, cells):
    cells.pop(-1)  # 删除link列
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值