pytest-pretty

1.3.0 · active · verified Sat Apr 11

pytest-pretty is an opinionated pytest plugin designed to enhance the readability of test output and simplify the process of identifying and resolving errors. It provides features such as a real-time error summary, a rich, tabulated display of failures, and a more visually appealing overall summary of the test run. The current version is 1.3.0, and while its release cadence is irregular, the project is actively maintained.

Warnings

Install

Imports

Quickstart

After installing `pytest-pretty`, simply run `pytest` from your terminal in a directory containing your test files (e.g., `test_example.py`). The plugin will automatically enhance the test summary, error reporting, and overall output. For optimal display in CI/CD environments like GitHub Actions, it's recommended to set the `COLUMNS` environment variable to a sufficient width.

# test_example.py

def test_passing_example():
    assert 1 + 1 == 2

def test_failing_example():
    # This assertion will fail to demonstrate the pretty failure output
    assert {"a": 1, "b": 2} == {"a": 1, "b": 3}

# To run the tests, navigate to the directory containing test_example.py
# and run the following command in your terminal:
# pytest

# For GitHub Actions, consider adding:
# env:
#   COLUMNS: 120
# to your workflow .yml file for better output formatting.

view raw JSON →