@Mr.Tian 你可以参考使用 pytest 的 hook 机制,文档在这里http://docs.pytest.org/en/latest/writing_plugins.html#writing-hook-functions
你可以在你的 conftest.py 中实现下面的这些 hook 函数,你可以自己选择一个符合你要求的 hook 函数来实现
pytest_itemcollected(item)[source]
we just collected a test item.
pytest_collectreport(report)[source]
collector finished collecting.
pytest_deselected(items)[source]
called for test items deselected by keyword.
pytest_report_header(config, startdir)[source]
return a string to be displayed as header info for terminal reporting.
pytest_report_teststatus(report)[source]
return result-category, shortletter and verbose word for reporting.