A pytest plugin that provides elegant, beautiful test output inspired by Pest PHP's aesthetic.
- Clean, minimal output with ✓/✗ symbols instead of dots/F/E
- Colored results - green for passing tests, red for failures, yellow for skipped
- File grouping - Tests organized by file with PASS/FAIL headers
- Duration display - See how long each test takes (e.g.,
0.12s) - Immediate failure details - See what went wrong right away with code context
- Zero configuration - Just install and run
pytestas usual - Standard pytest syntax - Keep your existing
def test_*functions
uv add --dev pytest-elegantpip install pytest-elegantOnce installed, pytest-elegant automatically transforms your pytest output. Just run:
pytestThat's it! No configuration needed.
Before (standard pytest):
After (with pytest-elegant):
Before (standard pytest):
After (with pytest-elegant):
After (with pytest-elegant with verbose mode):
pytest-elegant works out of the box, but you can customize it via pytest.ini or pyproject.toml.
[tool.pytest.ini_options]
elegant_show_context = true # Show code context in failure output (default: true)
elegant_group_by_file = true # Group test results by file (default: true)
elegant_show_duration = true # Show test duration for each test (default: true)[pytest]
elegant_show_context = true
elegant_group_by_file = true
elegant_show_duration = trueIf you need to temporarily disable pytest-elegant and see standard pytest output:
pytest --no-elegantpytest-elegant respects pytest's verbosity flags:
pytest -v # More details (full file paths, more context)
pytest -vv # Maximum details (full stack traces)pytest-elegant beautifully formats parametrized tests, showing each parameter set:
✓ test_math[1-2-3] 0.01s
✓ test_math[4-5-9] 0.01s
⨯ test_math[10-20-50] 0.02s
Test classes are handled with proper nesting:
PASS tests/test_user.py
✓ TestUser::test_creation 0.02s
✓ TestUser::test_validation 0.01s
Different test outcomes have distinct symbols:
✓- Passed (green)⨯- Failed (red)-- Skipped (yellow)x- Expected failure (yellow)X- Unexpected pass (yellow)
If your terminal doesn't support ✓/✗ symbols, pytest-elegant automatically falls back to ASCII alternatives (PASS/FAIL).
- Python: 3.14+
- pytest: 7.0.0+
- Terminal: Any terminal with ANSI color support
- Parallel testing: Compatible with pytest-xdist
pytest-elegant is a pytest plugin that:
- Registers via the
pytest11entry point - Replaces pytest's default
TerminalReporterwith a custom one - Customizes output formatting hooks to provide elegant, minimal output
- Uses pytest's built-in color support (no extra dependencies)
# Run all tests
pytest
# Run specific test file
pytest tests/test_reporter.pymypy src/pytest_elegantruff check src/pytest_elegantContributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Ensure all tests pass
- Submit a pull request
Yann Rabiller (@einenlum) | blog | From PHP to Python
MIT License - see LICENSE file for details
Heavily inspired by Pest PHP by Nuno Maduro and contributors.




