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

Possibly allowing better extensibility to html output #310

Open
memetb opened this issue Jun 24, 2020 · 6 comments
Open

Possibly allowing better extensibility to html output #310

memetb opened this issue Jun 24, 2020 · 6 comments
Labels
enhancement This issue/PR relates to a feature request. proposal This issue/PR is meant to gather feedback on an idea/change

Comments

@memetb
Copy link

memetb commented Jun 24, 2020

Hi,

I make use of pytest-html extensively and find the plugin generally fantastic.

In my usage, I have resorted to some substantial modifications to the output content. Recently I found myself going a bit too far and running regexes on output to alter them.

I think the following surgical changes would go a long way in avoiding such poor practices:

  • Wrapping body content in a div with class content
  • wrapping header in a div with class summary
  • and wrapping the results in a div with class results

The principal motivation of this would be to allow styling the output.

I think the biggest concern would be whether this will break a bunch of CI tests in the universe that have come to rely on the html output.

I apologize if this is a common request that gets closed repeatedly. I searched around in the issues but didn't find anything specifically asking this.

All three of these changes are trivial to implement and I could easily make a PR on short notice.

@BeyondEvil
Copy link
Contributor

I'd be happy to review a PR! We can always create a new breaking/major release. 👍 @memetb

@memetb
Copy link
Author

memetb commented Jun 28, 2020

@BeyondEvil I've done a full feature including documentation upate in the PR #311. Let me know if you have any concerns.

Thank you.

@christiansandberg
Copy link
Contributor

I just thought that I should add that I’ve developed a plug-in for generating reports using template engines as an alternative for those occasions you find yourself needing to do more heavy customization. It allows you to make a report from scratch or inherit an existing template and override parts of it.

pytest-reporter
pytest-reporter-html1

Sorry for the unsolicited advertisement. 🙄

@memetb
Copy link
Author

memetb commented Jul 10, 2020

Hey, thanks @christiansandberg. That looks quite nice at a glance. I will review it when I get some cycles.

@gnikonorov gnikonorov added enhancement This issue/PR relates to a feature request. proposal This issue/PR is meant to gather feedback on an idea/change labels Oct 23, 2020
@jkowalleck
Copy link
Contributor

jkowalleck commented Nov 28, 2020

maybe a switchable template should be used, instead of hooks/extends.

having the HTML generated via a template engine allowes better readability of output generators and does not need knowledge of python to apply changes of the outcome.
see https://www.makotemplates.org/ for example.

if there was a switch to use an own template instead of the shipped one would allow alternative output for everybody.

@christiansandberg
Copy link
Contributor

@jkowalleck see my earlier reply for a template based alternative. I also think there is a plan to switch pytest-html to JavaScript which hopefully will allow customization in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue/PR relates to a feature request. proposal This issue/PR is meant to gather feedback on an idea/change
Projects
None yet
Development

No branches or pull requests

5 participants