Python 3.x 如何为每个测试更改pytest html报告中显示的路径
我正在使用pytest html生成html报告。但在我的报告中,为每个测试用例运行显示了完整的路径。 我只想显示类名和测试用例名 在我的conftest.py文件中Python 3.x 如何为每个测试更改pytest html报告中显示的路径,python-3.x,pytest,pytest-html,Python 3.x,Pytest,Pytest Html,我正在使用pytest html生成html报告。但在我的报告中,为每个测试用例运行显示了完整的路径。 我只想显示类名和测试用例名 在我的conftest.py文件中 @pytest.mark.hookwrapper def pytest_runtest_makereport(item, call): pytest_html = item.config.pluginmanager.getplugin('html') outcome = yield report = outcome.g
@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
pytest_html = item.config.pluginmanager.getplugin('html')
outcome = yield
report = outcome.get_result()
report.description = str(item.function.__doc__)
extra = getattr(report, 'extra', [])
if report.when == 'call':
# always add url to report
extra.append(pytest_html.extras.url('http://www.example.com/'))
xfail = hasattr(report, 'wasxfail')
if (report.skipped and xfail) or (report.failed and not xfail):
# only add additional html on failure
extra.append(pytest_html.extras.html('<div>Additional HTML</div>'))
report.extra = extra
@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
pytest_html = item.config.pluginmanager.getplugin('html')
outcome = yield
report = outcome.get_result()
report.description = str(item.function.__doc__)
extra = getattr(report, 'extra', [])
if report.when == 'call':
# always add url to report
extra.append(pytest_html.extras.url('http://www.example.com/'))
xfail = hasattr(report, 'wasxfail')
if (report.skipped and xfail) or (report.failed and not xfail):
# only add additional html on failure
extra.append(pytest_html.extras.html('<div>Additional HTML</div>'))
report.extra = extra
@pytest.mark.hookwrapper
def pytest_runtest_makereport(项目,调用):
pytest_html=item.config.pluginmanager.getplugin('html'))
结果=产量
报告=结果。获取结果()
report.description=str(item.function.\uuuu doc\uuuu)
extra=getattr(报告“extra”和[])
如果report.when==“调用”:
#始终将url添加到报告
附加(pytest_html.extras.url('http://www.example.com/'))
xfail=hasattr(报告“wasxfail”)
如果(report.skipped和xfail)或(report.failed和not xfail):
#仅在失败时添加其他html
append(pytest_html.extras.html('Additional html'))
report.extra=额外
@pytest.mark.hookwrapper
def pytest_runtest_makereport(项目,调用):
pytest_html=item.config.pluginmanager.getplugin('html'))
结果=产量
报告=结果。获取结果()
report.description=str(item.function.\uuuu doc\uuuu)
extra=getattr(报告“extra”和[])
如果report.when==“调用”:
#始终将url添加到报告
附加(pytest_html.extras.url('http://www.example.com/'))
xfail=hasattr(报告“wasxfail”)
如果(report.skipped和xfail)或(report.failed和not xfail):
#仅在失败时添加其他html
append(pytest_html.extras.html('Additional html'))
report.extra=额外
实际结果:显示每个测试的完整路径
预期:只需要类名和测试用例名
您可能可以使用
os.environ.get('PYTEST\u CURRENT\u TEST')
您可能可以使用os.environ.get('PYTEST\u CURRENT\u TEST')
如果有人知道,请告诉我