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
[]

 

posted @ 2020-04-04 14:33  YouThIU  阅读(1170)  评论(0)    收藏  举报