pytest-review 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.
Files changed (42) hide show
  1. pytest_review-0.1.0/.gitignore +215 -0
  2. pytest_review-0.1.0/CHANGELOG.md +50 -0
  3. pytest_review-0.1.0/LICENSE +21 -0
  4. pytest_review-0.1.0/Makefile +121 -0
  5. pytest_review-0.1.0/PKG-INFO +238 -0
  6. pytest_review-0.1.0/README.md +206 -0
  7. pytest_review-0.1.0/examples/bad_tests.py +336 -0
  8. pytest_review-0.1.0/pyproject.toml +88 -0
  9. pytest_review-0.1.0/src/pytest_review/__init__.py +3 -0
  10. pytest_review-0.1.0/src/pytest_review/analyzers/__init__.py +35 -0
  11. pytest_review-0.1.0/src/pytest_review/analyzers/assertions.py +127 -0
  12. pytest_review-0.1.0/src/pytest_review/analyzers/base.py +167 -0
  13. pytest_review-0.1.0/src/pytest_review/analyzers/complexity.py +237 -0
  14. pytest_review-0.1.0/src/pytest_review/analyzers/isolation.py +247 -0
  15. pytest_review-0.1.0/src/pytest_review/analyzers/naming.py +148 -0
  16. pytest_review-0.1.0/src/pytest_review/analyzers/patterns.py +207 -0
  17. pytest_review-0.1.0/src/pytest_review/analyzers/performance.py +94 -0
  18. pytest_review-0.1.0/src/pytest_review/analyzers/smells.py +281 -0
  19. pytest_review-0.1.0/src/pytest_review/collectors/__init__.py +1 -0
  20. pytest_review-0.1.0/src/pytest_review/collectors/dynamic.py +78 -0
  21. pytest_review-0.1.0/src/pytest_review/config.py +85 -0
  22. pytest_review-0.1.0/src/pytest_review/plugin.py +407 -0
  23. pytest_review-0.1.0/src/pytest_review/reporters/__init__.py +7 -0
  24. pytest_review-0.1.0/src/pytest_review/reporters/html.py +467 -0
  25. pytest_review-0.1.0/src/pytest_review/reporters/json.py +152 -0
  26. pytest_review-0.1.0/src/pytest_review/reporters/terminal.py +140 -0
  27. pytest_review-0.1.0/src/pytest_review/scoring.py +214 -0
  28. pytest_review-0.1.0/tests/__init__.py +1 -0
  29. pytest_review-0.1.0/tests/conftest.py +27 -0
  30. pytest_review-0.1.0/tests/test_analyzers_base.py +253 -0
  31. pytest_review-0.1.0/tests/test_assertions_analyzer.py +153 -0
  32. pytest_review-0.1.0/tests/test_complexity_analyzer.py +168 -0
  33. pytest_review-0.1.0/tests/test_config.py +93 -0
  34. pytest_review-0.1.0/tests/test_isolation_analyzer.py +169 -0
  35. pytest_review-0.1.0/tests/test_naming_analyzer.py +128 -0
  36. pytest_review-0.1.0/tests/test_patterns_analyzer.py +226 -0
  37. pytest_review-0.1.0/tests/test_performance_analyzer.py +150 -0
  38. pytest_review-0.1.0/tests/test_plugin.py +103 -0
  39. pytest_review-0.1.0/tests/test_reporters.py +257 -0
  40. pytest_review-0.1.0/tests/test_scoring.py +285 -0
  41. pytest_review-0.1.0/tests/test_smells_analyzer.py +246 -0
  42. pytest_review-0.1.0/uv.lock +1203 -0
@@ -0,0 +1,215 @@
1
+ .DS_Store
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[codz]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py.cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # UV
100
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ #uv.lock
104
+
105
+ # poetry
106
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
107
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
108
+ # commonly ignored for libraries.
109
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
110
+ #poetry.lock
111
+ #poetry.toml
112
+
113
+ # pdm
114
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
115
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
116
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
117
+ #pdm.lock
118
+ #pdm.toml
119
+ .pdm-python
120
+ .pdm-build/
121
+
122
+ # pixi
123
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
124
+ #pixi.lock
125
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
126
+ # in the .venv directory. It is recommended not to include this directory in version control.
127
+ .pixi
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule
134
+ celerybeat.pid
135
+
136
+ # SageMath parsed files
137
+ *.sage.py
138
+
139
+ # Environments
140
+ .env
141
+ .envrc
142
+ .venv
143
+ env/
144
+ venv/
145
+ ENV/
146
+ env.bak/
147
+ venv.bak/
148
+
149
+ # Spyder project settings
150
+ .spyderproject
151
+ .spyproject
152
+
153
+ # Rope project settings
154
+ .ropeproject
155
+
156
+ # mkdocs documentation
157
+ /site
158
+
159
+ # mypy
160
+ .mypy_cache/
161
+ .dmypy.json
162
+ dmypy.json
163
+
164
+ # Pyre type checker
165
+ .pyre/
166
+
167
+ # pytype static type analyzer
168
+ .pytype/
169
+
170
+ # Cython debug symbols
171
+ cython_debug/
172
+
173
+ # PyCharm
174
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
175
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
176
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
177
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
178
+ #.idea/
179
+
180
+ # Abstra
181
+ # Abstra is an AI-powered process automation framework.
182
+ # Ignore directories containing user credentials, local state, and settings.
183
+ # Learn more at https://abstra.io/docs
184
+ .abstra/
185
+
186
+ # Visual Studio Code
187
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
188
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
189
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
190
+ # you could uncomment the following to ignore the entire vscode folder
191
+ # .vscode/
192
+
193
+ # Ruff stuff:
194
+ .ruff_cache/
195
+
196
+ # PyPI configuration file
197
+ .pypirc
198
+
199
+ # Cursor
200
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
201
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
202
+ # refer to https://docs.cursor.com/context/ignore-files
203
+ .cursorignore
204
+ .cursorindexingignore
205
+
206
+ # Marimo
207
+ marimo/_static/
208
+ marimo/_lsp/
209
+ __marimo__/
210
+
211
+ # agents
212
+ .claude
213
+ CLAUDE.md
214
+ AGENTS.md
215
+ GEMINI.md
@@ -0,0 +1,50 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0]
11
+
12
+ ### Added
13
+
14
+ - Initial release of pytest-review
15
+
16
+ #### Core Features
17
+ - pytest plugin integration with `--review` flag
18
+ - Quality scoring system with letter grades (A-F)
19
+ - Multiple output formats: terminal, JSON, HTML
20
+ - Configurable via `pyproject.toml`
21
+
22
+ #### Analyzers
23
+ - **assertions**: Detects empty tests, trivial assertions (`assert True`), tautologies
24
+ - **naming**: Checks for descriptive test names, snake_case convention, minimum length
25
+ - **complexity**: Flags high statement count, deep nesting, cyclomatic complexity
26
+ - **patterns**: Identifies anti-patterns (bare except, `time.sleep`, print statements, `os.system`)
27
+ - **isolation**: Detects global state modifications, class attribute mutations
28
+ - **performance**: Tracks slow tests at runtime
29
+ - **smells**: Detects test smells (assertion roulette, duplicate asserts, eager tests, magic numbers, skipped tests)
30
+
31
+ #### CLI Options
32
+ - `--review`: Enable test quality review
33
+ - `--review-format`: Output format (terminal/json/html)
34
+ - `--review-output`: Write report to file
35
+ - `--review-strict`: Fail if quality errors are found
36
+ - `--review-min-score`: Minimum required score (0-100)
37
+ - `--review-only`: Run specific analyzers only
38
+
39
+ #### Reporters
40
+ - Terminal reporter with colored output
41
+ - JSON reporter with structured data
42
+ - HTML reporter with styled dashboard
43
+
44
+ ### Acknowledgments
45
+
46
+ The smells analyzer is inspired by the [pytest-smell](https://github.com/maxpacs98/disertation) project.
47
+ Test smell concepts based on research by Van Deursen et al. and Meszaros.
48
+
49
+ [Unreleased]: https://github.com/shakeeb-alireza/pytest-review/compare/v0.1.0...HEAD
50
+ [0.1.0]: https://github.com/shakeeb-alireza/pytest-review/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Shakeeb Alireza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,121 @@
1
+ .PHONY: install dev test lint type-check clean all review review-html review-json \
2
+ example example-html example-json example-only example-strict example-min-score \
3
+ example-verify build publish publish-test check
4
+
5
+ all: install test
6
+
7
+ install:
8
+ @uv sync --reinstall-package pytest_review
9
+
10
+ dev:
11
+ @uv pip install -e .
12
+
13
+ test:
14
+ @uv run pytest
15
+
16
+ test-cov:
17
+ @uv run pytest --cov=pytest_review --cov-report=term-missing
18
+
19
+ review:
20
+ @uv run pytest --review
21
+
22
+ review-html:
23
+ @uv run pytest --review --review-format=html --review-output=pytest-review-report.html
24
+ @echo "HTML report generated: pytest-review-report.html"
25
+
26
+ review-json:
27
+ @uv run pytest --review --review-format=json --review-output=pytest-review-report.json
28
+ @echo "JSON report generated: pytest-review-report.json"
29
+
30
+ # Example targets using bad_tests.py
31
+ example:
32
+ @uv run pytest examples/bad_tests.py --review
33
+
34
+ example-html:
35
+ @uv run pytest examples/bad_tests.py --review --review-format=html --review-output=examples/report.html
36
+ @echo "HTML report generated: examples/report.html"
37
+
38
+ example-json:
39
+ @uv run pytest examples/bad_tests.py --review --review-format=json --review-output=examples/report.json
40
+ @echo "JSON report generated: examples/report.json"
41
+
42
+ example-only:
43
+ @uv run pytest examples/bad_tests.py --review --review-only=assertions,naming
44
+
45
+ example-strict:
46
+ @uv run pytest examples/bad_tests.py --review --review-strict || true
47
+
48
+ example-min-score:
49
+ @uv run pytest examples/bad_tests.py --review --review-min-score=70
50
+
51
+ # Verify all analyzers detect expected issues
52
+ example-verify:
53
+ @echo "Verifying all analyzers detect expected issues..."
54
+ @uv run pytest examples/bad_tests.py --review --review-format=json --review-output=/tmp/review.json -q
55
+ @uv run python -c "\
56
+ import json; \
57
+ data = json.load(open('/tmp/review.json')); \
58
+ rules = {i['rule'] for i in data['issues']}; \
59
+ expected = { \
60
+ 'assertions.missing', 'assertions.trivial', \
61
+ 'naming.non_descriptive', 'naming.too_short', 'naming.not_snake_case', \
62
+ 'complexity.too_many_statements', 'complexity.deep_nesting', 'complexity.high_cyclomatic', \
63
+ 'patterns.bare_except', 'patterns.sleep_in_test', 'patterns.print_statement', \
64
+ 'patterns.os_system', 'patterns.is_literal', \
65
+ 'isolation.global_modification', 'isolation.class_attr_modification', \
66
+ 'smells.assertion_roulette', 'smells.duplicate_assert', 'smells.ignored_test', \
67
+ 'smells.magic_number', 'smells.eager_test', \
68
+ }; \
69
+ missing = expected - rules; \
70
+ extra = rules - expected - {'naming.unclear_abbreviation'}; \
71
+ print(f'Found {len(rules)} unique rules'); \
72
+ print(f'Expected {len(expected)} rules'); \
73
+ [print(f' MISSING: {r}') for r in sorted(missing)]; \
74
+ [print(f' (extra): {r}') for r in sorted(extra)]; \
75
+ exit(1 if missing else 0) \
76
+ "
77
+ @echo "All expected rules detected!"
78
+
79
+ lint:
80
+ @uv run ruff check src/ tests/
81
+ @uv run ruff format --check src/ tests/
82
+
83
+ format:
84
+ @uv run ruff check --fix src/ tests/
85
+ @uv run ruff format src/ tests/
86
+
87
+ type-check:
88
+ @uv run mypy src/
89
+
90
+ clean:
91
+ @rm -rf build/
92
+ @rm -rf dist/
93
+ @rm -rf *.egg-info/
94
+ @rm -rf src/*.egg-info/
95
+ @rm -rf .pytest_cache/
96
+ @rm -rf .mypy_cache/
97
+ @rm -rf .ruff_cache/
98
+ @rm -rf htmlcov/
99
+ @rm -rf .coverage
100
+ @rm -f pytest-review-report.html
101
+ @rm -f pytest-review-report.json
102
+ @rm -f examples/report.html
103
+ @rm -f examples/report.json
104
+ @rm -f examples/bad_tests_report.html
105
+ @find . -type d -name __pycache__ -exec rm -rf {} +
106
+
107
+ # Build and publish
108
+ build: clean
109
+ @uv build
110
+ @echo "Build complete. Distribution files in dist/"
111
+
112
+ check: build
113
+ @uv run twine check dist/*
114
+
115
+ publish-test: check
116
+ @uv run twine upload --repository testpypi dist/*
117
+ @echo "Published to TestPyPI"
118
+
119
+ publish: check
120
+ @uv run twine upload dist/*
121
+ @echo "Published to PyPI"
@@ -0,0 +1,238 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-review
3
+ Version: 0.1.0
4
+ Summary: A pytest plugin that reviews the quality of your tests
5
+ Project-URL: Homepage, https://github.com/shakeeb-alireza/pytest-review
6
+ Project-URL: Repository, https://github.com/shakeeb-alireza/pytest-review
7
+ Author-email: Shakeeb Alireza <me@example.org>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: code-quality,code-review,linter,pytest,pytest-plugin,static-analysis,test-quality,testing
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Framework :: Pytest
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Requires-Python: >=3.9
24
+ Requires-Dist: pytest>=7.0.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
27
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
28
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
29
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
30
+ Requires-Dist: twine>=4.0.0; extra == 'dev'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # pytest-review
34
+
35
+ A pytest plugin that reviews the quality of your tests.
36
+
37
+ [![PyPI version](https://badge.fury.io/py/pytest-review.svg)](https://badge.fury.io/py/pytest-review)
38
+ [![Python versions](https://img.shields.io/pypi/pyversions/pytest-review.svg)](https://pypi.org/project/pytest-review/)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
40
+
41
+ ## Overview
42
+
43
+ pytest-review analyzes your test suite and provides actionable feedback on test quality. It detects common anti-patterns, missing assertions, overly complex tests, and more.
44
+
45
+ ## Features
46
+
47
+ - **Static Analysis**: AST-based detection of test quality issues
48
+ - **Dynamic Analysis**: Runtime performance tracking
49
+ - **Multiple Output Formats**: Terminal, JSON, and HTML reports
50
+ - **Configurable**: Customize thresholds and enable/disable analyzers
51
+ - **Quality Scoring**: Get a letter grade (A-F) for your test suite
52
+
53
+ ### Analyzers
54
+
55
+ | Analyzer | Description |
56
+ |----------|-------------|
57
+ | **assertions** | Detects empty tests, trivial assertions (`assert True`), tautologies |
58
+ | **naming** | Checks for descriptive test names, proper snake_case |
59
+ | **complexity** | Flags tests with too many statements, deep nesting, high cyclomatic complexity |
60
+ | **patterns** | Identifies anti-patterns: bare except, `time.sleep`, print statements |
61
+ | **isolation** | Detects global state modifications, class attribute mutations |
62
+ | **performance** | Tracks slow tests at runtime |
63
+ | **smells** | Detects test smells: assertion roulette, duplicate asserts, eager tests, magic numbers |
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ pip install pytest-review
69
+ ```
70
+
71
+ ## Quick Start
72
+
73
+ Run pytest with the `--review` flag:
74
+
75
+ ```bash
76
+ pytest --review
77
+ ```
78
+
79
+ Example output:
80
+
81
+ ```
82
+ ====================== pytest-review: Test Quality Report ======================
83
+ [X] tests/test_example.py:15 [test_empty] Test has no assertions
84
+ Suggestion: Add at least one assertion to verify expected behavior
85
+ [!] tests/test_example.py:20 [test_complex] Test has cyclomatic complexity of 12
86
+ Suggestion: Simplify test logic or split into multiple tests
87
+ ----------------------------------- Summary ------------------------------------
88
+ Tests analyzed: 25
89
+ Errors: 2
90
+ Warnings: 5
91
+ Info: 3
92
+ Quality: NEEDS IMPROVEMENT
93
+
94
+ Overall Score: 72.0/100 (C)
95
+ ================================================================================
96
+ ```
97
+
98
+ ## Command Line Options
99
+
100
+ | Option | Description |
101
+ |--------|-------------|
102
+ | `--review` | Enable test quality review |
103
+ | `--review-format` | Output format: `terminal` (default), `json`, `html` |
104
+ | `--review-output` | Write report to file |
105
+ | `--review-strict` | Fail if quality errors are found |
106
+ | `--review-min-score` | Minimum required score (0-100) |
107
+ | `--review-only` | Comma-separated list of analyzers to run |
108
+
109
+ ### Examples
110
+
111
+ ```bash
112
+ # Generate HTML report
113
+ pytest --review --review-format=html --review-output=report.html
114
+
115
+ # Generate JSON report
116
+ pytest --review --review-format=json --review-output=report.json
117
+
118
+ # Run only specific analyzers
119
+ pytest --review --review-only=assertions,naming
120
+
121
+ # Fail CI if score below 80
122
+ pytest --review --review-min-score=80
123
+
124
+ # Strict mode: fail on any errors
125
+ pytest --review --review-strict
126
+ ```
127
+
128
+ ## Configuration
129
+
130
+ Configure pytest-review in your `pyproject.toml`:
131
+
132
+ ```toml
133
+ [tool.pytest-review]
134
+ enabled = true
135
+ strict = false
136
+ min_score = 0
137
+
138
+ [tool.pytest-review.analyzers]
139
+ assertions = { enabled = true, min_assertions = 1 }
140
+ naming = { enabled = true, min_length = 10 }
141
+ complexity = { enabled = true, max_statements = 20, max_depth = 3, max_complexity = 5 }
142
+ patterns = { enabled = true }
143
+ isolation = { enabled = true }
144
+ performance = { enabled = true, slow_threshold_ms = 500, very_slow_threshold_ms = 2000 }
145
+ smells = { enabled = true, max_assertions_without_message = 1, check_magic_numbers = true }
146
+ ```
147
+
148
+ ### Skipping Tests
149
+
150
+ Use the `review_skip` marker to exclude specific tests from review:
151
+
152
+ ```python
153
+ import pytest
154
+
155
+ @pytest.mark.review_skip
156
+ def test_intentionally_complex():
157
+ # This test won't be analyzed
158
+ ...
159
+ ```
160
+
161
+ ## Scoring System
162
+
163
+ The quality score is calculated using weighted categories:
164
+
165
+ | Category | Weight | Analyzers |
166
+ |----------|--------|-----------|
167
+ | Assertions | 30% | assertions |
168
+ | Clarity | 25% | naming, smells |
169
+ | Isolation | 20% | isolation |
170
+ | Simplicity | 15% | complexity, patterns |
171
+ | Performance | 10% | performance |
172
+
173
+ Severity penalties:
174
+ - **Error**: -15 points per issue
175
+ - **Warning**: -5 points per issue
176
+ - **Info**: -1 point per issue
177
+
178
+ Critical penalties (applied globally):
179
+ - Missing assertions: -20 points
180
+ - Trivial assertions: -10 points
181
+
182
+ ### Grade Scale
183
+
184
+ | Grade | Score Range |
185
+ |-------|-------------|
186
+ | A | 90-100 |
187
+ | B | 80-89 |
188
+ | C | 70-79 |
189
+ | D | 60-69 |
190
+ | F | 0-59 |
191
+
192
+ ## Issue Types
193
+
194
+ ### Errors (X)
195
+
196
+ Critical issues that indicate likely bugs or useless tests:
197
+
198
+ - `assertions.missing` - Test has no assertions
199
+ - `assertions.trivial` - Trivial assertion like `assert True`
200
+ - `assertions.tautology` - Comparing value to itself
201
+
202
+ ### Warnings (!)
203
+
204
+ Issues that may indicate problems:
205
+
206
+ - `naming.non_descriptive` - Generic names like `test_foo`
207
+ - `complexity.too_many_statements` - Test too long
208
+ - `complexity.too_deep` - Excessive nesting
209
+ - `complexity.too_complex` - High cyclomatic complexity
210
+ - `patterns.bare_except` - Catches all exceptions
211
+ - `patterns.sleep_in_test` - Uses `time.sleep()`
212
+ - `isolation.global_modification` - Modifies global state
213
+ - `smells.assertion_roulette` - Multiple assertions without messages
214
+ - `smells.duplicate_assert` - Duplicate assertion statements
215
+ - `smells.ignored_test` - Test is skipped with decorator
216
+
217
+ ### Info (i)
218
+
219
+ Suggestions for improvement:
220
+
221
+ - `naming.too_short` - Name could be more descriptive
222
+ - `patterns.print_statement` - Debug print left in test
223
+ - `performance.slow_test` - Test runs slowly
224
+ - `smells.magic_number` - Literal number in assertion
225
+ - `smells.eager_test` - Test verifies multiple methods
226
+
227
+ ## Acknowledgments
228
+
229
+ - The smells analyzer is inspired by the [pytest-smell](https://github.com/maxpacs98/disertation) project from the dissertation "Detecting Test Smells in Python" by Maxim Pacsial.
230
+ - Test smell concepts are based on research by Van Deursen et al. ("Refactoring Test Code", 2001) and Meszaros ("xUnit Test Patterns", 2007).
231
+
232
+ ## Contributing
233
+
234
+ Contributions are welcome! Please feel free to submit a Pull Request.
235
+
236
+ ## License
237
+
238
+ MIT License - see [LICENSE](LICENSE) for details.