Package: pytest-difido
pytest-difidoPyTest plugin for creating flexible and informative test reportsThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesFlexible locally generated HTML report on the running machineReports are generated at runtime. No need to wait for test execution to endEasily attach files and images to the reportWorks also in remote mode. You can addDifido serverthat allows publishing reports to central serverConsole reports - Reports to the console in addition to the HTML output mainly for development phase and CI/CD systemsExtensible - Allows to implement and add additional reportersRequirementsPyTest >= 4.0.0Python >= 3InstallationYou can install “pytest-difido” viapipfromPyPI:$ pip install pytest-difidoUsageTo use the report, add the report fixture to your test cases. You can report simple message, links, HTML elements and moredeftest_messaging(report):# Simple message will be added to the reportreport.that("Simple report message")# link to Googlereport.link(title='Google',link=r'http:\\www.google.com')# Message will be hidden inside toggle elementreport.start_level("start toggle")report.that("In toggle")report.stop_level()# Message will appear in bold fontreport.step("bold message")# HTML element will be added to the reportreport.html("Table","""

        <table>

      <tr>

        <th>Company</th>

        <th>Contact</th>

      </tr>

      <tr>

        <td>ACME Corporation</td>

        <td>Road Bumper</td>

      </tr>

      <tr>

        <td>DOLO Inc</td>

        <td>Wired Coyote</td>

      </tr>

    </table>

        """)Files and images can be attached to the HTML report. The files are copied to the local and remote reports.deftest_files(report):# File will be copied and attached to the reportreport.file(file_path=os.path.join("resources","some_file.txt"),description="My text file")# Image will added with thumbnailreport.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.deftest_add_properties(report):# Property will be added to the executionreport.add_execution_properties("int_Execution","66")# Property will be added to the current running testreport.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 theReportclass.The ‘Report’ class is implemented as singleton so you will always get the same instancedeftest_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

    """fromdifido.report_managerimportReportreport=Report()report.that("very important message")Server InstallationThis step isnotmandatory. Local reports will be generated also without the Difido server. Follow this step only if you wish tohave central server for publishing test results. If all you need is local reports that will be generated on the running machine, skip this stepDownload the latest Difido server ZIP file from theDifido releasespageExtract the content of the fileRun the ‘[root]/bin/start.bat’ or ‘[root]/bin/start.sh’ file according to your OS.Set the host and port in the client configuration as shown in the next sectionAdd the ‘difido.reporters.RemoteReporter’ to the ‘df_reporters’ list in the configuration. More information about reporters can be found in the ‘Reporters’ sectionYou can access the server from your browser (E.Ghttp://localhost:8080/). For more information please refer to theDifido server Wiki pageConfigurationYou can configure the reporter from thepytest.inifile or from the command line.In the case where a parameter is defined using both methods, the value defined from the command line takes precedencepytest.ini examples[pytest]; Host or ip of Difido server. Default localhostdf_host=192.168.0.13; Port of Difido server. Default 8080df_port=8090; Result folder for HTML and console reports. Default is current directorydf_output_folder=/etc/log/; Reporters are defined in the following comma-separated listdf_reporters=difido.reporters.LocalReporter,difido.reporters.RemoteReporter,difido.reporters.ConsoleReporterCommand line example$ pytest .\tests\test_report_examples.py --df_host=192.168.10.1 --df_port=8090Configuration Propertiesdf_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 managerdf_description- Description of test execution as shown in the Difido serverReportersReporters 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 folderdifido.reporters.RemoteReporter- Pulishes results to the Difido serverdifido.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.ConsoleReporterYou can also implement your own reporter and add it to the list.ContributingContributions are very welcome. Tests can be run withtox, please ensurethe coverage at least stays the same before you submit a pull request.LicenseDistributed under the terms of theApache Software License 2.0license, “pytest-difido” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.