Skip to main content

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

Project description

===================== pytest-custom_outputs

Features

  • Useful for if you want more than just the default Pass, Fail, and Skip outcomes.
  • Allows for the creation and usage of custom outputs.
  • Custom outputs are filled out in a file called "pytest_custom_outputs.json".
  • Custom outputs are customizable in their name, description, result code, tag, and color.
  • Supports the creation of an unknown output. If no result matches a default or custom output, then it will be categorized as an unknown output.
  • Unknown outputs are also fully customizable.

Requirements

None

Installation

You can install "pytest-custom_outputs" via pip_ from PyPI_::

$ 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.

EXAMPLE FILE: ###STARTS HERE### { "use_unknown_if_no_match": true, "unknown": { "attribute":"_unknown", "status": { "desc":"unknown", "code":"?", "output": { "tag":"UNKNOWN", "color":"purple" } } }, "custom_outputs": { "Pass_with_exception": { "attribute":"_expected_pass", "status": { "desc":"passed_with_exception", "code":"P", "output": { "tag":"XPASSED", "color":"green" } } }, "Fatal_failed": { "attribute":"_fatal_fail", "status": { "desc":"fatal_failed", "code":"!", "output": { "tag":"FAILED", "color":"red" } } }, "Not_available": { "attribute":"_not_available", "status": { "desc":"not_available", "code":"N", "output": { "tag":"NOT_AVAILABLE", "color":"blue" } } }, "Failed_but_proceed": { "attribute":"_fail_but_proceed", "status": { "desc":"failed_but_proceed", "code":"X", "output": { "tag":"FAILED_BUT_PROCEED", "color":"red" } } }, "Unimplemented": { "attribute":"_unimplemented", "status": { "desc":"unimplemented", "code":"U", "output": { "tag":"UNIMPLEMENTED", "color":"yellow" } } }, "Skipped": { "attribute":"_skipped", "status": { "desc":"skipped", "code":"S", "output": { "tag":"SKIPPED", "color":"yellow" } } } } } ###ENDS HERE###

use_unknown_if_no_match -> If True, use the unknown output below if there is no match. Otherwise, use standard skip unknown -> The output to use if a test's result is not in default or custom outputs custom_outputs -> A dictionary with all the custom outputs you write 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. This is done by using skip followed by the name in the parameter.

For example: import pytest from pytest import skip

    def test_1():
            skip("Pass_with_exception")

In the example above, test_1 will result in "passed_with_exception". Because the name overrides the outcome, it will not result in a skip. We use the keyword skip as a means to obtaining out desired outcome.

If we put a name that is not in our custom output in the skip parameter, then if we set unknown to True in the json, we will use the unknown outcome else we will use the default skip and pass the name as a message (Standard skip behavior)

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

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.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _@hackebrot: https://github.com/hackebrot .. _MIT: https://opensource.org/licenses/MIT .. _BSD-3: https://opensource.org/licenses/BSD-3-Clause .. _GNU GPL v3.0: https://www.gnu.org/licenses/gpl-3.0.txt .. _Apache Software License 2.0: https://www.apache.org/licenses/LICENSE-2.0 .. _cookiecutter-pytest-plugin: https://github.com/pytest-dev/cookiecutter-pytest-plugin .. _file an issue: https://github.com/MichaelE55/pytest-custom_outputs/issues .. _pytest: https://github.com/pytest-dev/pytest .. _tox: https://tox.readthedocs.io/en/latest/ .. _pip: https://pypi.org/project/pip/ .. _PyPI: https://pypi.org/project

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.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

pytest_custom_outputs-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_custom_outputs-0.1.0.tar.gz
  • Upload date:
  • Size: 6.2 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.1.0.tar.gz
Algorithm Hash digest
SHA256 7ea3c589811b43d051e3c391c148c8d7146ffb16a8e7b4dcac05acce02c09b91
MD5 9f88237c81f2d5f30efa0b8d444bdb26
BLAKE2b-256 43a5e679c9889c2e90e81971cbddc5f4fbbab472a08a52a1bfdf1640a134d1bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_custom_outputs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ff5f74a005340651fd91980a5a8031aaaa4899b2ec7f3bf600cee6c0901df06
MD5 8647cb63b085f39475ab0ac22430df37
BLAKE2b-256 48c861c0788355cac76e9ed13378c60b0903406c7600e9678cafb41855cb11e8

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