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