Skip to main content

A plugin that allows users to create and use custom outputs instead of the standard Pass and Fail

Project description

Enhance Your Pytest Reporting with Customizable Test Outputs

Tired of the standard pass/fail binary in pytest? With pytest-custom_outputs, you can create expressive and informative custom test results that go beyond the ordinary. Tailor your reports to provide deeper insights into your test scenarios.

Useful for if you want more than just the default Pass, Fail, and Skip outcomes.

Features

  • Flexible Output Types: Define new outcome types like "unimplemented", "soft_fail"," "inconclusive," or any custom label that suits your testing needs.
  • Fully Customizeable: Custom outputs are customizable in their name, description, result code, tag, and color.
  • Seamless Integration: Easily incorporate custom outputs into your existing pytest test suites.
  • Terminal and File Reporting: View your custom outputs in both your terminal output and pytest file reports.

Installation

pip install pytest-custom_outputs

Usage

In the directory where you will be running your pytest, create a file called "pytest_custom_outputs.json". You will use this file to create your own custom outputs. Feel free to copy and paste the below json file into yours and edit from there.

EXAMPLE FILE:

{
        "custom_outputs": {
                "Pass_with_exception": {
                        "desc":"passed_with_exception",
                        "code":"P",
                        "tag":"XPASSED",
                        "color":"green"
                },
                "Fatal_failed": {
                        "desc":"fatal_failed",
                        "code":"!",
                        "tag":"FAILED",
                        "color":"red"
                },
                "Not_available": {
                        "desc":"not_available",
                        "code":"N",
                        "tag":"NOT_AVAILABLE",
                        "color":"blue"
                },
                "Failed_but_proceed": {
                        "desc":"failed_but_proceed",
                        "code":"X",
                        "tag":"FAILED_BUT_PROCEED",
                        "color":"red"
                },
                "Unimplemented": {
                        "desc":"unimplemented",
                        "code":"U",
                        "tag":"UNIMPLEMENTED",
                        "color":"yellow"
                },
                "Skipped": {
                        "desc":"skipped",
                        "code":"S",
                        "tag":"SKIPPED",
                        "color":"yellow"
                }
        }
}

custom_outputs

  • A dictionary with all the custom outputs inside of it. You can edit, delete, and add new outputs here.

Each custom output is denoted by a name. The name is also the key for that output For example, in the above example file, "Pass_with_exception" and "Fatal_failed" are the names for their respective output. Names are also how we determine the result of a test case. We use the c_assert function and enter the name as an argument to assert that specific output.

For example:

import pytest
from pytest_custom_outputs import c_assert

def test_1():
    c_assert("Pass_with_exception")

In the example above, test_1 will result in "passed_with_exception".

If we put a name that is not in our custom output in the c_assert parameter, then it will assert the unknown outcome Because of this, it is recommended to not make a custom output with the name "unknown"

The rest of the information in the json file can be edited and customized to your liking.

Why pytest-custom_outputs?

  • Improved Communication: Get more informative insights from your test runs
  • Focus on Key Areas: Prioritize test cases that require attention
  • Tailored for Your Needs: Adapt outcomes and messages to your project's specific requirements

Contributing

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.

License

Distributed under the terms of the BSD-3_ license, "pytest-custom_outputs" is free and open source software

Issues

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

.. _file an issue: https://github.com/MichaelE55/pytest-custom_outputs/issues

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_custom_outputs-0.2.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

pytest_custom_outputs-0.2.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pytest_custom_outputs-0.2.2.tar.gz.

File metadata

  • Download URL: pytest_custom_outputs-0.2.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.10

File hashes

Hashes for pytest_custom_outputs-0.2.2.tar.gz
Algorithm Hash digest
SHA256 b60d2cd89127d0942df5b9e0adbed4f668617ebd01fa400a90681095f607b9ef
MD5 fab687a9a23404fdf36ec78bd31ba542
BLAKE2b-256 bb80f125ee3c897af8dcb80d27537b32944e4e104a3cc0680258b68098b0cd0e

See more details on using hashes here.

File details

Details for the file pytest_custom_outputs-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_custom_outputs-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cf4ce045566cf16d384844abd176822200607e03b2757a75537d916b2ae8473b
MD5 be93d5d5f80f885637ad9e94f32e4eab
BLAKE2b-256 aa7ae45c71bf604ba915bcdcac5c6194ca9d042b4a699961672c3196d693a86a

See more details on using hashes here.

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