christiansandberg / pytest-reporter

Template based report generation for Pytest
MIT License
15 stars 2 forks source link

Neet to set the report path from script #6

Open dkjha52 opened 3 years ago

dkjha52 commented 3 years ago

I want to set the report path from script (conftest.py). Please let me know the scripts for that so i can set --report=report.html from script.

christiansandberg commented 3 years ago

This is not possible at the moment, but you can copy the report to another location using the pytest_reporter_finish hook.

def pytest_reporter_finish(path, context, config):
    # Copy or move path to another location
dkjha52 commented 3 years ago

Thanks for the response. Can you please help me to provide sample scripts..

quanlidavid commented 1 year ago

I think you can change report path in this hook. Add below in your conftest.py

def pytest_reporter_context(context, config):
    config.option.report[0] = config.option.report[0].replace('.html', str(datetime.datetime.now().strftime(
        "%Y-%m-%d-%H-%M-%S")) + '.html')