pytest-elegant
A pytest plugin that provides elegant, beautiful test output inspired by Pest PHP's aesthetic.
Features
- 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
Installation
Using uv (recommended)
uv add --dev pytest-elegant
Using pip
pip install pytest-elegant
Usage
Once installed, pytest-elegant automatically transforms your pytest output. Just run:
pytest
That's it! No configuration needed.
Successful Example Output
Before (standard pytest):
After (with pytest-elegant):
Failure Example Output
Before (standard pytest):
After (with pytest-elegant):
After (with pytest-elegant with verbose mode):
Configuration
pytest-elegant works out of the box, but you can customize it via pytest.ini or pyproject.toml.
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.ini
[pytest]
elegant_show_context = true
elegant_group_by_file = true
elegant_show_duration = true
Disabling pytest-elegant
If you need to temporarily disable pytest-elegant and see standard pytest output:
pytest --no-elegant
Verbose Mode
pytest-elegant respects pytest's verbosity flags:
pytest -v # More details (full file paths, more context)
pytest -vv # Maximum details (full stack traces)
Advanced Features
Parametrized Tests
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
Test classes are handled with proper nesting:
PASS tests/test_user.py
✓ TestUser::test_creation 0.02s
✓ TestUser::test_validation 0.01s
Skipped and Expected Failures
Different test outcomes have distinct symbols:
✓- Passed (green)⨯- Failed (red)-- Skipped (yellow)x- Expected failure (yellow)X- Unexpected pass (yellow)
Unicode Support
If your terminal doesn't support ✓/✗ symbols, pytest-elegant automatically falls back to ASCII alternatives (PASS/FAIL).
Compatibility
- Python: 3.14+
- pytest: 7.0.0+
- Terminal: Any terminal with ANSI color support
- Parallel testing: Compatible with pytest-xdist
How It Works
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)
Development
Running Tests
# Run all tests
pytest
# Run specific test file
pytest tests/test_reporter.py
Type Checking
mypy src/pytest_elegant
Linting
ruff check src/pytest_elegant
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Ensure all tests pass
- Submit a pull request
Author
Yann Rabiller (@einenlum) | blog | From PHP to Python
License
MIT License - see LICENSE file for details
Credits
Heavily inspired by Pest PHP by Nuno Maduro and contributors.
Metadata
Release files for pytest-elegant 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_elegant-0.2.0.tar.gz | 16.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_elegant-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.0 kB
Release files / pytest_elegant-0.2.0.tar.gz
| Download URL | pytest_elegant-0.2.0.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d074aaff387140b22feaf5337dfe3b19aa0ec77f04f4bb034178a3b36dc16f1
|
|
BLAKE2b-256 checksum How to use checksums |
28643c9104834533c3813988f26cff0e90bbd1c001c48bbb87e6f0dd8ef1ad47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.7
|
Release files / pytest_elegant-0.2.0-py3-none-any.whl
| Download URL | pytest_elegant-0.2.0-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41fed04cdf807b39431f4e86895c720b614414b72ded6aa38d7dd2d2f62285ed
|
|
BLAKE2b-256 checksum How to use checksums |
790ef4bb6df612bbdec5ed412af12a34489bb0985aae2ca561d5bec84bd008c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.7
|