<div dir="ltr">Hi Dave,<div><br></div><div>Congratulations on this initiative to separate this functionality into a separate plugin, it seems very useful! :)</div><div><br></div><div>One way to allow other plugins to interact with yours is by defining your own hooks. Pytest-xdist does this[1], and as an example, the builtin hook pytest_report_header[2] seems to do something similar to what you want, in the sense that it allows other plugins to add information to the terminal header.</div><div><br></div><div>Perhaps you can declare a hook `pytest_html_report_environment`, which plugins can implement and return a dict of environment variables to be added to the report? Or perhaps, if it makes sense for the environment details to appear in the terminal output as well, you could in fact just call `pytest_report_header` and add its contents into the HTML; the latter has the benefit that existing plugins which already use `pytest_report_header` will be able to write their information to the HTML report.</div><div><br></div><div>Cheers,</div><div><br></div><div>[1] <a href="https://bitbucket.org/pytest-dev/pytest-xdist/src/00cfff4834e718fd3c1ccec40811e734d796f631/xdist/newhooks.py">https://bitbucket.org/pytest-dev/pytest-xdist/src/00cfff4834e718fd3c1ccec40811e734d796f631/xdist/newhooks.py</a><br></div><div>[2] <a href="http://pytest.org/latest/example/simple.html?highlight=pytest_report_header#adding-info-to-test-report-header">http://pytest.org/latest/example/simple.html?highlight=pytest_report_header#adding-info-to-test-report-header</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 15, 2015 at 12:05 PM, Dave Hunt <span dir="ltr"><<a href="mailto:dhunt@mozilla.com" target="_blank">dhunt@mozilla.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hey py.testers!<div><br></div><div>I’ve been working on pulling a feature out of our pytest-mozwebqa plugin into a standalone plugin. I think others may find it useful, and it would simplify maintenance of the former plugin to split this out. Please take a look over the pytest-html plugin, the source code is available here: <a href="https://github.com/davehunt/pytest-html" target="_blank">https://github.com/davehunt/pytest-html</a></div><div><br></div><div>Basically this plugin provides a new command line option of —html which allows the user to specify a path for a HTML report to be generated. The report can then be enhanced by adding extra components via  the pytest_runtest_makereport hook. You can see an example of this in my in-progress branch of pytest-mozwebqa where I’ve switched to using the new plugin: <a href="https://github.com/davehunt/pytest-mozwebqa/blob/1074f0770a146cff3108191a2fe239d15cfd92e4/pytest_mozwebqa/pytest_mozwebqa.py#L126" target="_blank">https://github.com/davehunt/pytest-mozwebqa/blob/1074f0770a146cff3108191a2fe239d15cfd92e4/pytest_mozwebqa/pytest_mozwebqa.py#L126</a></div><div><br></div><div>What I’d like some help with is providing the HTML report with environment details. This is essentially just a dictionary that will be included in the HTML report, but should be optionally provided by another plugin or conftest.py file. At the moment I accept an environment keyword argument when instantiating the HTMLReport object, but I’m not aware of a way to influence this from another plugin. See: <a href="https://github.com/davehunt/pytest-html/blob/752f229b990c80e66195374a4ed4fe22b98017c6/pytest_html.py#L44" target="_blank">https://github.com/davehunt/pytest-html/blob/752f229b990c80e66195374a4ed4fe22b98017c6/pytest_html.py#L44</a> and <a href="https://github.com/davehunt/pytest-html/blob/752f229b990c80e66195374a4ed4fe22b98017c6/pytest_html.py#L195" target="_blank">https://github.com/davehunt/pytest-html/blob/752f229b990c80e66195374a4ed4fe22b98017c6/pytest_html.py#L195</a></div><div><br></div><div>If anybody has any advice it would be much appreciated!</div><div><br></div><div>Thanks in advance,<br><div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br>--</div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><strong>Dave Hunt</strong></div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div>Automation Engineer<br>Mozilla Corporation<br><a href="mailto:dhunt@mozilla.com" target="_blank">dhunt@mozilla.com</a></div></div>
</div>
<br></div></div><br>_______________________________________________<br>
pytest-dev mailing list<br>
<a href="mailto:pytest-dev@python.org">pytest-dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/pytest-dev" target="_blank">https://mail.python.org/mailman/listinfo/pytest-dev</a><br>
<br></blockquote></div><br></div>