Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to store pytest-html-reporter generated report to a custom location #228

Open
xiaoguren opened this issue May 9, 2023 · 1 comment

Comments

@xiaoguren
Copy link

I am using pytest-html-reporter 0.2.9 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

@GambetaClub
Copy link

Could you solve this? I want to do the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants