pytest-elegant 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,205 @@
1
+ Metadata-Version: 2.3
2
+ Name: pytest-elegant
3
+ Version: 0.1.0
4
+ Summary: A pytest plugin that provides elegant, beautiful test output
5
+ Author: Einenlum
6
+ Author-email: Einenlum <contact@einenlum.com>
7
+ Requires-Dist: pytest>=7.0.0
8
+ Requires-Dist: rich>=13.0.0
9
+ Requires-Python: >=3.14
10
+ Description-Content-Type: text/markdown
11
+
12
+ # pytest-elegant
13
+
14
+ A pytest plugin that provides elegant, beautiful test output inspired by [Pest PHP](https://pestphp.com/)'s aesthetic.
15
+
16
+ ## Features
17
+
18
+ - **Clean, minimal output** with ✓/✗ symbols instead of dots/F/E
19
+ - **Colored results** - green for passing tests, red for failures, yellow for skipped
20
+ - **File grouping** - Tests organized by file with PASS/FAIL headers
21
+ - **Duration display** - See how long each test takes (e.g., `0.12s`)
22
+ - **Immediate failure details** - See what went wrong right away with code context
23
+ - **Zero configuration** - Just install and run `pytest` as usual
24
+ - **Standard pytest syntax** - Keep your existing `def test_*` functions
25
+
26
+ ## Installation
27
+
28
+ ### Using uv (recommended)
29
+
30
+ ```bash
31
+ uv add --dev pytest-elegant
32
+ ```
33
+
34
+ ### Using pip
35
+
36
+ ```bash
37
+ pip install pytest-elegant
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ Once installed, pytest-elegant automatically transforms your pytest output. Just run:
43
+
44
+ ```bash
45
+ pytest
46
+ ```
47
+
48
+ That's it! No configuration needed.
49
+
50
+ ### Successful Example Output
51
+
52
+ **Before (standard pytest):**
53
+
54
+ ![](assets/success-pytest.png)
55
+
56
+ **After (with pytest-elegant):**
57
+
58
+ ![](assets/success-pytest-elegant.png)
59
+
60
+ ### Failure Example Output
61
+
62
+ **Before (standard pytest):**
63
+
64
+ ![](assets/failure-pytest.png)
65
+
66
+ **After (with pytest-elegant):**
67
+
68
+ ![](assets/failure-pytest-elegant.png)
69
+
70
+ **After (with pytest-elegant with verbose mode):**
71
+
72
+ ![](assets/failure-pytest-elegant-verbose.png)
73
+
74
+ ## Configuration
75
+
76
+ pytest-elegant works out of the box, but you can customize it via `pytest.ini` or `pyproject.toml`.
77
+
78
+ ### pyproject.toml
79
+
80
+ ```toml
81
+ [tool.pytest.ini_options]
82
+ elegant_show_context = true # Show code context in failure output (default: true)
83
+ elegant_group_by_file = true # Group test results by file (default: true)
84
+ elegant_show_duration = true # Show test duration for each test (default: true)
85
+ ```
86
+
87
+ ### pytest.ini
88
+
89
+ ```ini
90
+ [pytest]
91
+ elegant_show_context = true
92
+ elegant_group_by_file = true
93
+ elegant_show_duration = true
94
+ ```
95
+
96
+ ## Disabling pytest-elegant
97
+
98
+ If you need to temporarily disable pytest-elegant and see standard pytest output:
99
+
100
+ ```bash
101
+ pytest --no-elegant
102
+ ```
103
+
104
+ ## Verbose Mode
105
+
106
+ pytest-elegant respects pytest's verbosity flags:
107
+
108
+ ```bash
109
+ pytest -v # More details (full file paths, more context)
110
+ pytest -vv # Maximum details (full stack traces)
111
+ ```
112
+
113
+ ## Advanced Features
114
+
115
+ ### Parametrized Tests
116
+
117
+ pytest-elegant beautifully formats parametrized tests, showing each parameter set:
118
+
119
+ ```
120
+ ✓ test_math[1-2-3] 0.01s
121
+ ✓ test_math[4-5-9] 0.01s
122
+ ⨯ test_math[10-20-50] 0.02s
123
+ ```
124
+
125
+ ### Test Classes
126
+
127
+ Test classes are handled with proper nesting:
128
+
129
+ ```
130
+ PASS tests/test_user.py
131
+ ✓ TestUser::test_creation 0.02s
132
+ ✓ TestUser::test_validation 0.01s
133
+ ```
134
+
135
+ ### Skipped and Expected Failures
136
+
137
+ Different test outcomes have distinct symbols:
138
+
139
+ - `✓` - Passed (green)
140
+ - `⨯` - Failed (red)
141
+ - `-` - Skipped (yellow)
142
+ - `x` - Expected failure (yellow)
143
+ - `X` - Unexpected pass (yellow)
144
+
145
+ ### Unicode Support
146
+
147
+ If your terminal doesn't support ✓/✗ symbols, pytest-elegant automatically falls back to ASCII alternatives (`PASS`/`FAIL`).
148
+
149
+ ## Compatibility
150
+
151
+ - **Python**: 3.14+
152
+ - **pytest**: 7.0.0+
153
+ - **Terminal**: Any terminal with ANSI color support
154
+ - **Parallel testing**: Compatible with pytest-xdist
155
+
156
+ ## How It Works
157
+
158
+ pytest-elegant is a pytest plugin that:
159
+
160
+ 1. Registers via the `pytest11` entry point
161
+ 2. Replaces pytest's default `TerminalReporter` with a custom one
162
+ 3. Customizes output formatting hooks to provide elegant, minimal output
163
+ 4. Uses pytest's built-in color support (no extra dependencies)
164
+
165
+ ## Development
166
+
167
+ ### Running Tests
168
+
169
+ ```bash
170
+ # Run all tests
171
+ pytest
172
+
173
+ # Run specific test file
174
+ pytest tests/test_reporter.py
175
+ ```
176
+
177
+ ### Type Checking
178
+
179
+ ```bash
180
+ mypy src/pytest_elegant
181
+ ```
182
+
183
+ ### Linting
184
+
185
+ ```bash
186
+ ruff check src/pytest_elegant
187
+ ```
188
+
189
+ ## Contributing
190
+
191
+ Contributions welcome! Please:
192
+
193
+ 1. Fork the repository
194
+ 2. Create a feature branch
195
+ 3. Add tests for new features
196
+ 4. Ensure all tests pass
197
+ 5. Submit a pull request
198
+
199
+ ## License
200
+
201
+ MIT License - see LICENSE file for details
202
+
203
+ ## Credits
204
+
205
+ Heavily inspired by [Pest PHP](https://pestphp.com/) by Nuno Maduro and contributors.
@@ -0,0 +1,194 @@
1
+ # pytest-elegant
2
+
3
+ A pytest plugin that provides elegant, beautiful test output inspired by [Pest PHP](https://pestphp.com/)'s aesthetic.
4
+
5
+ ## Features
6
+
7
+ - **Clean, minimal output** with ✓/✗ symbols instead of dots/F/E
8
+ - **Colored results** - green for passing tests, red for failures, yellow for skipped
9
+ - **File grouping** - Tests organized by file with PASS/FAIL headers
10
+ - **Duration display** - See how long each test takes (e.g., `0.12s`)
11
+ - **Immediate failure details** - See what went wrong right away with code context
12
+ - **Zero configuration** - Just install and run `pytest` as usual
13
+ - **Standard pytest syntax** - Keep your existing `def test_*` functions
14
+
15
+ ## Installation
16
+
17
+ ### Using uv (recommended)
18
+
19
+ ```bash
20
+ uv add --dev pytest-elegant
21
+ ```
22
+
23
+ ### Using pip
24
+
25
+ ```bash
26
+ pip install pytest-elegant
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ Once installed, pytest-elegant automatically transforms your pytest output. Just run:
32
+
33
+ ```bash
34
+ pytest
35
+ ```
36
+
37
+ That's it! No configuration needed.
38
+
39
+ ### Successful Example Output
40
+
41
+ **Before (standard pytest):**
42
+
43
+ ![](assets/success-pytest.png)
44
+
45
+ **After (with pytest-elegant):**
46
+
47
+ ![](assets/success-pytest-elegant.png)
48
+
49
+ ### Failure Example Output
50
+
51
+ **Before (standard pytest):**
52
+
53
+ ![](assets/failure-pytest.png)
54
+
55
+ **After (with pytest-elegant):**
56
+
57
+ ![](assets/failure-pytest-elegant.png)
58
+
59
+ **After (with pytest-elegant with verbose mode):**
60
+
61
+ ![](assets/failure-pytest-elegant-verbose.png)
62
+
63
+ ## Configuration
64
+
65
+ pytest-elegant works out of the box, but you can customize it via `pytest.ini` or `pyproject.toml`.
66
+
67
+ ### pyproject.toml
68
+
69
+ ```toml
70
+ [tool.pytest.ini_options]
71
+ elegant_show_context = true # Show code context in failure output (default: true)
72
+ elegant_group_by_file = true # Group test results by file (default: true)
73
+ elegant_show_duration = true # Show test duration for each test (default: true)
74
+ ```
75
+
76
+ ### pytest.ini
77
+
78
+ ```ini
79
+ [pytest]
80
+ elegant_show_context = true
81
+ elegant_group_by_file = true
82
+ elegant_show_duration = true
83
+ ```
84
+
85
+ ## Disabling pytest-elegant
86
+
87
+ If you need to temporarily disable pytest-elegant and see standard pytest output:
88
+
89
+ ```bash
90
+ pytest --no-elegant
91
+ ```
92
+
93
+ ## Verbose Mode
94
+
95
+ pytest-elegant respects pytest's verbosity flags:
96
+
97
+ ```bash
98
+ pytest -v # More details (full file paths, more context)
99
+ pytest -vv # Maximum details (full stack traces)
100
+ ```
101
+
102
+ ## Advanced Features
103
+
104
+ ### Parametrized Tests
105
+
106
+ pytest-elegant beautifully formats parametrized tests, showing each parameter set:
107
+
108
+ ```
109
+ ✓ test_math[1-2-3] 0.01s
110
+ ✓ test_math[4-5-9] 0.01s
111
+ ⨯ test_math[10-20-50] 0.02s
112
+ ```
113
+
114
+ ### Test Classes
115
+
116
+ Test classes are handled with proper nesting:
117
+
118
+ ```
119
+ PASS tests/test_user.py
120
+ ✓ TestUser::test_creation 0.02s
121
+ ✓ TestUser::test_validation 0.01s
122
+ ```
123
+
124
+ ### Skipped and Expected Failures
125
+
126
+ Different test outcomes have distinct symbols:
127
+
128
+ - `✓` - Passed (green)
129
+ - `⨯` - Failed (red)
130
+ - `-` - Skipped (yellow)
131
+ - `x` - Expected failure (yellow)
132
+ - `X` - Unexpected pass (yellow)
133
+
134
+ ### Unicode Support
135
+
136
+ If your terminal doesn't support ✓/✗ symbols, pytest-elegant automatically falls back to ASCII alternatives (`PASS`/`FAIL`).
137
+
138
+ ## Compatibility
139
+
140
+ - **Python**: 3.14+
141
+ - **pytest**: 7.0.0+
142
+ - **Terminal**: Any terminal with ANSI color support
143
+ - **Parallel testing**: Compatible with pytest-xdist
144
+
145
+ ## How It Works
146
+
147
+ pytest-elegant is a pytest plugin that:
148
+
149
+ 1. Registers via the `pytest11` entry point
150
+ 2. Replaces pytest's default `TerminalReporter` with a custom one
151
+ 3. Customizes output formatting hooks to provide elegant, minimal output
152
+ 4. Uses pytest's built-in color support (no extra dependencies)
153
+
154
+ ## Development
155
+
156
+ ### Running Tests
157
+
158
+ ```bash
159
+ # Run all tests
160
+ pytest
161
+
162
+ # Run specific test file
163
+ pytest tests/test_reporter.py
164
+ ```
165
+
166
+ ### Type Checking
167
+
168
+ ```bash
169
+ mypy src/pytest_elegant
170
+ ```
171
+
172
+ ### Linting
173
+
174
+ ```bash
175
+ ruff check src/pytest_elegant
176
+ ```
177
+
178
+ ## Contributing
179
+
180
+ Contributions welcome! Please:
181
+
182
+ 1. Fork the repository
183
+ 2. Create a feature branch
184
+ 3. Add tests for new features
185
+ 4. Ensure all tests pass
186
+ 5. Submit a pull request
187
+
188
+ ## License
189
+
190
+ MIT License - see LICENSE file for details
191
+
192
+ ## Credits
193
+
194
+ Heavily inspired by [Pest PHP](https://pestphp.com/) by Nuno Maduro and contributors.
@@ -0,0 +1,48 @@
1
+ [project]
2
+ name = "pytest-elegant"
3
+ version = "0.1.0"
4
+ description = "A pytest plugin that provides elegant, beautiful test output"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Einenlum", email = "contact@einenlum.com" }
8
+ ]
9
+ requires-python = ">=3.14"
10
+ dependencies = [
11
+ "pytest>=7.0.0",
12
+ "rich>=13.0.0",
13
+ ]
14
+
15
+ [project.entry-points.pytest11]
16
+ pytest_elegant = "pytest_elegant.plugin"
17
+
18
+ [tool.pytest.ini_options]
19
+ testpaths = ["tests"]
20
+ python_files = "test_*.py"
21
+ python_classes = "Test*"
22
+ python_functions = "test_*"
23
+ norecursedirs = ["fixtures"]
24
+
25
+ # pytest-elegant configuration options (all default to true)
26
+ # elegant_show_context = true # Show code context in failure output
27
+ # elegant_group_by_file = true # Group test results by file with PASS/FAIL headers
28
+ # elegant_show_duration = true # Show test duration for each test
29
+
30
+ [tool.ruff]
31
+ line-length = 88
32
+ target-version = "py314"
33
+
34
+ [tool.mypy]
35
+ python_version = "3.14"
36
+ warn_return_any = true
37
+ warn_unused_configs = true
38
+ disallow_untyped_defs = true
39
+
40
+ [build-system]
41
+ requires = ["uv_build>=0.9.7,<0.10.0"]
42
+ build-backend = "uv_build"
43
+
44
+ [dependency-groups]
45
+ dev = [
46
+ "mypy>=1.19.1",
47
+ "ruff>=0.15.5",
48
+ ]
@@ -0,0 +1,72 @@
1
+ """pytest-elegant: Pytest plugin for elegant output.
2
+
3
+ pytest-elegant transforms pytest's test output to provide elegant, beautiful formatting
4
+ with minimal, clean output using ✓/✗ symbols, file grouping, and colored results.
5
+
6
+ Features:
7
+ - Clean, minimal output with ✓/✗ symbols instead of dots/F/E
8
+ - Group tests by file with PASS/FAIL headers
9
+ - Show test duration for each test
10
+ - Display failures immediately with code context
11
+ - Colored output (green/red/yellow) for better readability
12
+ - Works with standard pytest `def test_*` syntax
13
+ - No changes to test code required
14
+
15
+ Installation:
16
+ pip install pytest-elegant
17
+
18
+ Usage:
19
+ Simply install the plugin and run pytest normally. pytest-elegant will automatically
20
+ format the output. To disable, use the --no-elegant flag:
21
+
22
+ pytest # Elegant output (default)
23
+ pytest --no-elegant # Standard pytest output
24
+
25
+ Configuration:
26
+ Options can be set in pytest.ini or pyproject.toml:
27
+
28
+ [tool.pytest.ini_options]
29
+ elegant_show_context = true # Show code context in failures
30
+ elegant_group_by_file = true # Group tests by file
31
+ elegant_show_duration = true # Show test durations
32
+
33
+ Example Output:
34
+ PASS tests/test_math.py
35
+ ✓ test_addition 0.01s
36
+ ✓ test_subtraction 0.01s
37
+
38
+ FAIL tests/test_user.py
39
+ ✓ test_user_creation 0.05s
40
+ ⨯ test_user_validation 0.03s
41
+ ────────────────────────────────────────
42
+ AssertionError: assert False
43
+ File "tests/test_user.py", line 12
44
+ → 12 assert user.is_valid()
45
+
46
+ Tests: 3 passed, 1 failed, 4 total
47
+ Duration: 0.10s
48
+
49
+ Modules:
50
+ plugin: Pytest hook implementations for integrating pytest-elegant
51
+ reporter: ElegantTerminalReporter class for formatting output
52
+ utils: Helper functions for formatting and terminal operations
53
+
54
+ Classes:
55
+ ElegantTerminalReporter: Custom terminal reporter for elegant output
56
+
57
+ Functions:
58
+ pytest_configure: Hook to register the custom reporter
59
+ pytest_report_teststatus: Hook to customize test status symbols
60
+ """
61
+
62
+ __version__ = "0.1.0"
63
+
64
+ from pytest_elegant.reporter import ElegantTerminalReporter
65
+ from pytest_elegant.plugin import pytest_configure, pytest_report_teststatus
66
+
67
+ __all__ = [
68
+ "__version__",
69
+ "ElegantTerminalReporter",
70
+ "pytest_configure",
71
+ "pytest_report_teststatus",
72
+ ]