pytest-sugar

1.1.1 · active · verified Thu Apr 09

pytest-sugar is a plugin for the pytest testing framework that enhances its default output with a cleaner, more readable progress bar and immediate feedback on failing tests. It is actively maintained, currently at version 1.1.1, and releases new versions to support new pytest features or address compatibility issues.

Warnings

Install

Quickstart

Install the library and pytest. Create a simple test file. Run `pytest` from your terminal, and pytest-sugar's enhanced output will be automatically applied. No explicit imports are needed for basic usage.

# 1. Install pytest and pytest-sugar
# pip install pytest pytest-sugar

# 2. Create a test file (e.g., test_example.py)
# Then run pytest from your terminal in the same directory.

# --- test_example.py ---
import time
import pytest

def test_passing_example():
    assert True

def test_failing_example():
    assert False

@pytest.mark.parametrize("i", range(3))
def test_parametrized_example(i):
    time.sleep(0.1) # Simulate some work
    assert i < 2 # One will fail

def test_long_running_example():
    time.sleep(0.5)
    assert True

# 3. Run tests using pytest (pytest-sugar is automatically enabled):
#    pytest

view raw JSON →