Skip to content
Advertisement

customize html table of pytest with docstring of the test

I have a pytest test function as below.

def test_mytest():
    ''' this is my awesome test '''
    assert 1==1 

I’d like to print this test_mytest.docstring in the html report as a column between test and duration columns. I could gather that the pytest_runtest_makereport() pytest.mark.hookwrapper could help. Is there any code snippets that I can use as a reference to make the modification

Advertisement

Answer

Fortunately the exact example is mention in the pytest-html user guide. https://pytest-html.readthedocs.io/en/latest/user_guide.html#modifying-the-results-table A mere copy paste of the example adds the docstring to the title

Advertisement