[Python] How to attach log files to the pytest HTML report?

Discussão em 'Python' iniciado por Stack, Setembro 8, 2025.

  1. Stack

    Stack Membro Participativo

    How do I attach log files in the HTML report generated while running pytest using pytest --html=report.html command?

    test_addition.py:

    def test_addition():
    fh = open("a.log")
    # write to above log file and save
    fh.close()
    assert 1 + 1 == 2


    Command:

    pytest --html=report.html


    I want the log file a.log attached as a link in the HTML report generated by pytest.

    Continue reading...

Compartilhe esta Página