pytest之pytest_runtest_makereport(item, call)


1、此钩子函数在测试用例运行的不同阶段(setup, call, teardown)都会被调用一次

def pytest_runtest_makereport(item, call):
    """
  返回一个_pytest.runner.TestReport类对象
每个测试用例执行后,制作测试报告 :param item:测试用例对象 :param call:测试用例的测试步骤,   _pytest.runner.CallInfo对象   先执行when=’setup’ 返回setup 的执行结果 然后执行when=’call’ 返回call 的执行结果 最后执行when=’teardown’返回teardown 的执行结果 :return: """ print(item) print(call) print(call.when) print(call.result)

2、执行结果

testcase/test_getRegionCountry/test_GetRegionCountry.py::test_getRightrequest <Function test_getRightrequest>
<CallInfo when='setup' result: []>
setup
[]
<Function test_getRightrequest>
<CallInfo when='call' result: []>
call
[]
PASSED<Function test_getRightrequest>
<CallInfo when='teardown' result: []>
teardown
[]

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM