Skip to main content

PyTest plugin for generating Difido reports

Project description


PyTest plugin for creating flexible and informative test reports

This pytest plugin was generated with Cookiecutter along with @hackebrot’s cookiecutter-pytest-plugin template.


  • Flexible locally generated HTML report on the running machine

  • Reports are generated at runtime. No need to wait for test execution to end

  • Easily attach files and images to the report

  • Works also in remote mode. You can add Difido server that allows publishing reports to central server

  • Console reports - Reports to the console in addition to the HTML output mainly for development phase and CI/CD systems

  • Extensible - Allows to implement and add additional reporters


  • PyTest >= 4.0.0

  • Python >= 3


You can install “pytest-difido” via pip from PyPI:

$ pip install pytest-difido


To use the report, add the report fixture to your test cases. You can report simple message, links, HTML elements and more

def test_messaging(report):

    # Simple message will be added to the report

    report.that("Simple report message")

    # link to Google'Google', link=r'http:\\')

    # Message will be hidden inside toggle element

    report.start_level("start toggle")

    report.that("In toggle")


    # Message will appear in bold font

    report.step("bold message")

    # HTML element will be added to the report

    report.html("Table", """







        <td>ACME Corporation</td>

        <td>Road Bumper</td>



        <td>DOLO Inc</td>

        <td>Wired Coyote</td>




Files and images can be attached to the HTML report. The files are copied to the local and remote reports.

def test_files(report):

    # File will be copied and attached to the report

    report.file(file_path=os.path.join("resources", "some_file.txt"), description="My text file")

    # Image will added with thumbnail

    report.img(img_path=os.path.join("resources", "cat.jpg"), description="Cats are awesome")

Properties can be added to the suite or to each test. The properties are disaplyed in the report and, if ElasticSearch integration is enabled, can be searched.

def test_add_properties(report):

    # Property will be added to the execution

    report.add_execution_properties("int_Execution", "66")

    # Property will be added to the current running test

    report.add_test_property("double_testProp", "1.56")

If you prefer to use to report without fixtures, or if you want to use it from places other then your test cases, you can intantiate the Report class.

The ‘Report’ class is implemented as singleton so you will always get the same instance

def test_report_without_fixture():


    If you don't want to get the reporter as fixture or if you want to use it not from test method

    you can just instantiate the Report class. The Report class is implemented as Singleton


    from difido.report_manager import Report

    report = Report()

    report.that("very important message")

Server Installation

This step is not mandatory. Local reports will be generated also without the Difido server. Follow this step only if you wish to

have central server for publishing test results. If all you need is local reports that will be generated on the running machine, skip this step

  • Download the latest Difido server ZIP file from the Difido releases page

  • Extract the content of the file

  • Run the ‘[root]/bin/start.bat’ or ‘[root]/bin/’ file according to your OS.

  • Set the host and port in the client configuration as shown in the next section

  • Add the ‘difido.reporters.RemoteReporter’ to the ‘df_reporters’ list in the configuration. More information about reporters can be found in the ‘Reporters’ section

You can access the server from your browser (E.G http://localhost:8080/). For more information please refer to the Difido server Wiki page


You can configure the reporter from the pytest.ini file or from the command line.

In the case where a parameter is defined using both methods, the value defined from the command line takes precedence

pytest.ini examples


; Host or ip of Difido server. Default localhost

df_host =

; Port of Difido server. Default 8080

df_port = 8090

; Result folder for HTML and console reports. Default is current directory

df_output_folder = /etc/log/

; Reporters are defined in the following comma-separated list

df_reporters = difido.reporters.LocalReporter,difido.reporters.RemoteReporter,difido.reporters.ConsoleReporter

Command line example

$ pytest .\tests\ --df_host= --df_port=8090

Configuration Properties

  • df_output_folder - Result folder for HTML and console reports (default .)

  • df_host - Host or ip of Difido server (default localhost)

  • df_port - Difido server port (default 8080)

  • df_reporters - Comma-separated list of reporter classes. The all reporters recieves the event from the report manager

  • df_description - Description of test execution as shown in the Difido server


Reporters are Python classes that translates the events recieved from the tests and generates a single report format.

The plugin currently includes three types of reporters:

  • difido.reporters.LocalReporter - Generates local HTML reports to the repors output folder

  • difido.reporters.RemoteReporter - Pulishes results to the Difido server

  • difido.reporters.ConsoleReporter - Writes to the conole. At the end of the run the output is also copied to a file in the reports output folder.

You can decide which reporters you want to enabled by adding or removing the classes from the ‘df_reporters’ list.

By default, only the ‘LocalReporter’ and ‘ConsoleReporter’ are included in the list. To use the remote reporter, for example, you will need to add it by configuring the ‘df_reporters’ as following:

df_reporters = difido.reporters.LocalReporter,difido.reporters.RemoteReporter,difido.reporters.ConsoleReporter

You can also implement your own reporter and add it to the list.


Contributions are very welcome. Tests can be run with tox, please ensure

the coverage at least stays the same before you submit a pull request.


Distributed under the terms of the Apache Software License 2.0 license, “pytest-difido” is free and open source software


If you encounter any problems, please file an issue along with a detailed description.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-difido-0.5.1.tar.gz (293.7 kB view hashes)

Uploaded source

Built Distribution

pytest_difido-0.5.1-py3-none-any.whl (291.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page