Skip to main content

Live Rich-rendered step trees in pytest terminal output

Project description

pytest-step-logger

Live, colour-coded step trees in your pytest terminal — powered by Rich.

⟳ test_checkout
├── ✔ Create booking   3.01s
├── ▶ Call API         1.24s   ← running right now
└── ○ Validate response        ← pending

Steps transition in real time:

Symbol Colour Meaning
grey Not yet reached
yellow Currently running
green Passed
red Failed

Features

  • Allure support — step labels come from @allure.step("label") when available.
  • Plain-function fallback — when there is no allure, function names are used automatically (via sys.settrace).
  • Ahead-of-time tree — all steps appear as grey nodes before execution starts, so you see the full plan upfront.
  • Soft-assertion aware — failures from pytest-check are detected and colour the step red even though no exception propagates.
  • Caught-exception fix — a step that catches and swallows an exception is correctly left green.
  • pytest-xdist parallel support — a single persistent spinner panel shows every currently-running test with elapsed times; completed trees print above the panel without flicker.

Installation

pip install pytest-step-logger

With optional integrations:

# allure + pytest-check + xdist all at once
pip install "pytest-step-logger[all]"

# individual extras
pip install "pytest-step-logger[allure]"
pip install "pytest-step-logger[check]"
pip install "pytest-step-logger[xdist]"

Usage

Add --step-log to your pytest invocation:

pytest --step-log

Or make it permanent in pyproject.toml / pytest.ini:

[tool.pytest.ini_options]
addopts = "--step-log"

With allure steps

import allure

@allure.step("Create booking")
def create_booking():
    ...

@allure.step("Call API")
def call_api():
    ...

def test_checkout():
    create_booking()
    call_api()

With plain functions (no allure)

def create_booking():
    ...

def call_api():
    ...

def test_checkout():
    create_booking()
    call_api()

The plugin automatically detects the absence of allure and falls back to function names.

Parallel execution (pytest-xdist)

pytest --step-log -n auto

While tests run in parallel you see a live spinner panel:

  ⠋ test_checkout        2.3s
  ⠙ test_cancel_booking  1.1s
  ⠹ test_search          0.4s

As each test finishes its full step tree is printed above the panel.


How it works

Scenario Step source Live display
Sequential, allure @allure.step hook via allure_commons.plugin_manager Per-test Live tree
Sequential, no allure sys.settrace call/return events Per-test Live tree
xdist worker Same as above (no TTY needed) None — serialised to report
xdist controller Deserialises worker reports Persistent spinner + printed trees

Step records are serialised as JSON into report.user_properties and survive xdist's wire protocol transparently.


Requirements

  • Python ≥ 3.11
  • pytest ≥ 7.0
  • rich ≥ 13.0

Optional:

  • allure-pytest ≥ 2.13
  • pytest-check ≥ 2.7.4
  • pytest-xdist ≥ 3.8.0

License

MIT

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_step_logger-0.1.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_step_logger-0.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_step_logger-0.1.0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_step_logger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3b03f63229157c4fb223d226e27c60e43b31c67da463c375ce6341c76016c0c6
MD5 71e8550fcfb39cefe360f18857912883
BLAKE2b-256 fc8177015803ebe609e42ea03122ebb802387a5c024e42b8506611d3ea389c3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_step_logger-0.1.0.tar.gz:

Publisher: publish.yml on Slaaayer/pytest-step-logger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for pytest_step_logger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58030843bab28ded3fba520b22163add0900ea54f8c7ae0a418b13bb0b6d05cb
MD5 ba8fe41e3cbf73412d052f2192096aae
BLAKE2b-256 1df35c3ed0998565f74f5602799f47948b0aa20cc5ff601107bca46430c8699e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_step_logger-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Slaaayer/pytest-step-logger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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