Complete the code to import the pytest-html plugin.
import pytest @pytest.mark.usefixtures([1]) def test_example(): assert 1 == 1
The pytest-html plugin is accessed via the fixture named pytest_html.
Complete the command to generate an HTML report using pytest-html.
pytest --[1]=report.htmlThe correct option to generate an HTML report is --html followed by the filename.
Fix the error in the pytest command to include extra metadata in the HTML report.
pytest --html=report.html --[1]='Project: Demo'
The correct option to add metadata is --metadata-add or use hooks; however, pytest-html uses --metadata to add key-value pairs. The option --metadata-add is invalid, so the correct option is --metadata.
Fill both blanks to add a hook function that modifies the HTML report title and environment info.
def pytest_html_report_title(report): report.title = [1] def pytest_html_environment(config): return [2]
The report title should be a string like "My Test Report". The environment info is a dictionary with key-value pairs describing the test environment.
Fill all three blanks to add a pytest hook that appends extra info to the HTML report.
def pytest_html_results_table_row(report, cells): if report.failed: cells.append([1]) @pytest.hookimpl(optionalhook=True) def pytest_html_results_table_header(cells): cells.append([2]) @pytest.hookimpl(optionalhook=True) def pytest_html_results_table_html(report, data): if report.failed: data.append([3])
td and th tags or using incorrect HTML elements.In the results table row, a table data cell td with failure details is appended. The header uses a table header cell th with 'Extra Info'. The HTML section appends a div with failure details.