2 years ago
#2490
Litz
Generate pytest-html report per module in a session
I understand that the HTML report is written in the pytest_sessionfinish
hookimpl (src). Which if i run multiple modules in one session, it will create only one report.
However, i would want to have one report for each module ran.
With my conftest.py containing:
@pytest.hookimpl(tryfirst=True)
def pytest_configure(config):
script_name = os.path.splitext(os.path.basename(lib_programname.get_path_executed_script()))[0]
if not os.path.exists('reports'):
os.makedirs('reports')
config.option.htmlpath = 'reports/'+ 'report_' + script_name + ".html"
config.option.self_contained_html = True
If i run: pytest .\test_One.py .\test_Two.py
. It generates only one html file, report_test_One.html
containing both module results.
However, is there a way i could add in on my conftest.py that it will create reports for each module ran instead of one per session? i.e. report_test_One.html
, report_test_Two.html
?
python
pytest
pytest-html
0 Answers
Your Answer