how to customize html report file generated using py.test?
<p>I am trying to customize html report using pytest.
For example, if I've got a directory structure like:</p>

<pre><code>tests
    temp1
         test_temp1.py
    conftest.py
</code></pre>

<p>A conftest.py file is also in the tests directory, and it should be common to all the sub-directories in the tests directory.
What fixtures and hookwrappers can I use in the conftest.py to change the contents of the html file generated using the following command:</p>

<blockquote>
  <p>py.test tests/temp1/test_temp1.py --html=report.html</p>
</blockquote>

<p>Looks like you are using some plugin like pytest-html. 
If that is the case check documentation for that plugin for what all hooks are provided.</p>

<p>for pytest-html following hooks are provided
You can add change the Environment section of the report by modifying <code>request.config._html.environment</code> from a fixture:</p>

<pre><code>@pytest.fixture(autouse=True)
def _environment(request):
    request.config._environment.append(('foo', 'bar'))
</code></pre>

<p>You can add details to the HTML reports by creating an âextraâ list on the report object. The following example adds the various types of extras using a <code>pytest_runtest_makereport</code> hook, which can be implemented in a plugin or <code>conftest.py</code> file:</p>

<pre><code>import pytest
@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
    pytest_html = item.config.pluginmanager.getplugin('html')
    outcome = yield
    report = outcome.get_result()
    extra = getattr(report, 'extra', [])
    if report.when == 'call':
        # always add url to report
        extra.append(pytest_html.extras.url('http://www.example.com/'))
        xfail = hasattr(report, 'wasxfail')
        if (report.skipped and xfail) or (report.failed and not xfail):
            # only add additional html on failure
            extra.append(pytest_html.extras.html('&lt;div&gt;Additional HTML&lt;/div&gt;'))
        report.extra = extra
</code></pre>

python html py.test