I am using pytest-html-reporter 0.2.4 plugin to generate execution reports. when i pass the command line argument "--html-report=./report/report.html" directly i am able to get the report in the given location.
I want to store the report in a seperate location with execution date(YYYYMMDD) as folder name and inside report_HHMM.html as the report name
This is the logic i am currently using
@pytest.hookimpl(tryfirst=True)
def pytest_configure(config):
time_var = datetime.datetime.now()
# create report target dir
reports_dir = Path('reports', time_var.strftime('%Y%m%d'))
reports_dir.mkdir(parents=True, exist_ok=True)
# line to be add for addopts
args = f"--html-report=./{reports_dir}/report_{time_var.strftime('%H%M')}.html"
config.addinivalue_line("addopts", args)
print("inside config function",config.getini("addopts"))
this is my pytest.ini file
[pytest]
python_files = test_*
python_functions = test_*
python_classes = *Tests
addopts =
using config.getini("addopts") i am able to see the report path getting added to the addopts,but there are no reports getting added to the created directory
If you wish to put the
pytest-html-reporter
report underfolderA
, you can just try thisor you can place them directly under the
pytest.ini
file