pytest-metadata icon indicating copy to clipboard operation
pytest-metadata copied to clipboard

Feature request: Support for adding your own sections

Open Stefanhg opened this issue 2 years ago • 5 comments

Hello, I wish to add my own section that includes test configurations so I can separate information about test env. and test config. Is it possible to add it already or is this a feature that would be needed? I tried to look though the source code but I can't figure out if the environment section is built into pytest-html or built into Python

Stefanhg avatar Aug 28 '23 16:08 Stefanhg

Not sure what exactly you're trying to do. Can you maybe elaborate a little more?

The environment section is part of pytest-html and you can add sections to that using the pytest-metadata plugin.

BeyondEvil avatar Aug 29 '23 07:08 BeyondEvil

What i want is to add my own completely isolated section. So I don't combine environment section and my own section as this section can become rather big with many configurations I would like to hide it.

I did conclude my own question. It is part of pytest-html and would be a feature request. I am working on right now trying to figure out how to access the set_data function though pytest session fixture but It seems like that might not be possible.

Here is a example of what I want: image

Stefanhg avatar Aug 29 '23 08:08 Stefanhg

You can more or less accomplish this using the pytest_html_results_summary hook.

BeyondEvil avatar Aug 29 '23 08:08 BeyondEvil

Yeah, it could just be moved to "Summary" instead of under environment. But this would require me to copy in the whole function of renderStatic and all of It's sub functions right? Or do you have a smarter idea in mind?

Stefanhg avatar Aug 29 '23 08:08 Stefanhg

You shouldn't have to copy or modify anything. Just build the HTML as you want it and pass it to the hook. The report will then render it.

BeyondEvil avatar Aug 29 '23 14:08 BeyondEvil