pytest-dev/pytest-html

support for pyproject.toml

Opened this issue · 6 comments

Hello!

pyproject.toml isn't supported and only pytest.ini to enable generate_report_on_test and I have an existing project that uses pyproject.toml with [tool.pytest.ini_options] since you can't use both at the same time, what would you recommend?

The ini option key in pyproject is equivalent to using pytest.ini

The ini option key in pyproject is equivalent to using pytest.ini

That's what I thought but it didn't work.

[tool.pytest.ini_options]
addopts="--html=report.html --self-contained-html"

I managed to get it working via the above.

However, the below does not work

[tool.pytest.ini_options]
generate_report_on_test = "True" 

@1Mark Here's some context for ya: https://realpython.com/python-toml/#strings-numbers-and-booleans

Take notice of the difference between between TOML and Python's boolean data type, specifically around capitalization :)
Long story short, try

[tool.pytest.ini_options]
generate_report_on_test = true

If that works feel free to close the issue (it should, I tested it!) :)

1Mark commented

@1Mark Here's some context for ya: https://realpython.com/python-toml/#strings-numbers-and-booleans

Take notice of the difference between between TOML and Python's boolean data type, specifically around capitalization :)
Long story short, try

[tool.pytest.ini_options]
generate_report_on_test = true

If that works feel free to close the issue (it should, I tested it!) :)

Thanks for looking into this. Will try and report back.