Skip to content

pgnikolov/pytest-enhanced

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงช pytest-enhanced

PyPI version Python version Tests License

Pytest Enhanced โ€” a smarter pytest companion that adds analytics, stability tracking, and CLI + web reports for developers who want insight, not just pass/fail output.


๐Ÿš€ Why pytest-enhanced?

Feature โœ… pytest-enhanced โšช vanilla pytest
Detect flaky tests โœ… Yes โŒ No
Show slowest tests โœ… Yes โšช Basic timing only
Pass-rate history โœ… Yes โŒ No
Persistent history (SQLite) โœ… Yes โŒ No
CSV / JSON export โœ… Yes โŒ No
HTML static reports โœ… Yes โŒ No
Web dashboard (FastAPI) โœ… Beta โŒ No
Rich CLI reports โœ… Yes โŒ Plain text
CI-ready analytics โœ… Yes โšช Limited

๐Ÿง  Built for developers who care about test reliability, not just test counts.


๐Ÿงฉ Features

  • ๐Ÿ“Š Analytics for your tests

    • Detect flaky or unstable tests automatically
    • Identify slow tests and performance bottlenecks
    • View historical pass-rate trends
  • โšก Zero configuration

    • Just run pytest --enhanced
    • Works with any test suite, immediately
  • ๐Ÿ’พ SQLite storage

    • Keeps history across multiple runs
    • Simple local database, no external services
  • ๐Ÿงฎ Export your test history

    • Export all test data to CSV or JSON
    • Perfect for CI pipelines or dashboards
  • ๐ŸŽจ Beautiful CLI reports

  • ๐Ÿงพ Static HTML reports

    • Generate sharable test reports with a single command

๐Ÿ“ฆ Installation

pip install pytest-enhanced

Or for development:

git clone https://github.com/pgnikolov/pytest-enhanced.git
cd pytest-enhanced
pip install -e .[dev]

๐Ÿง  Usage

Run your tests with enhanced tracking:

pytest --enhanced

Then view analytics:

pytest-enhanced report

Or inspect specific metrics:

pytest-enhanced slow
pytest-enhanced flaky
pytest-enhanced export --format csv

๐Ÿ“ˆ Example output

๐Ÿ“Š Pytest Enhanced Report โ€” Run #5
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Total tests: 8
Passed: 7  |  Failed: 1  |  Skipped: 0
Pass rate: 87.5%

๐Ÿข Slowest tests:
  demo_tests/test_sample.py::test_slow_one      1.24s
  demo_tests/test_sample.py::test_api_latency   0.93s

๐Ÿ”ฅ Flaky tests:
  test_random_fail                             2 fails / 10 runs (20.0%)

๐Ÿ“ˆ Pass rate trend:
  Run 5: 87.5%
  Run 4: 100.0%
  Run 3: 90.0%
  Run 2: 100.0%
  Run 1: 95.0%

โš™๏ธ CLI Commands

Command Description
pytest-enhanced report Show full analytics for the latest run
pytest-enhanced slow Display the slowest tests
pytest-enhanced flaky List flaky or unstable tests
pytest-enhanced export Export results to CSV or JSON
pytest-enhanced html Generate a static HTML report
pytest-enhanced web Start local FastAPI dashboard (beta)

๐Ÿ“ค Exporting test data

Export full history to CSV:

pytest-enhanced export --format csv --output results.csv

Or JSON:

pytest-enhanced export --format json --limit 100

Artifacts can be uploaded automatically in CI pipelines.


๐Ÿงพ HTML Reports

Generate a static HTML report of your test analytics โ€” ideal for CI artifacts or sharing with your team.

pytest-enhanced html --output report.html

Then open report.html in your browser.

It includes:

  • test summary
  • slowest tests
  • flaky tests
  • pass rate history

img.png

โ˜๏ธ Web Dashboard (FastAPI)

Launch a lightweight local dashboard to explore your pytest-enhanced data:

pytest-enhanced web

โžก Opens at http://127.0.0.1:8000

View:

  • historical runs
  • flaky test frequency
  • pass-rate trend over time

๐Ÿšง (Currently in beta, evolving towards interactive charts and filtering.)


๐Ÿ—‚๏ธ Project Structure

pytest-enhanced/
โ”œโ”€โ”€ pytest_enhanced/
โ”‚   โ”œโ”€โ”€ plugin.py          # pytest hooks
โ”‚   โ”œโ”€โ”€ storage.py         # SQLite logic
โ”‚   โ”œโ”€โ”€ analysis.py        # metrics & stats
โ”‚   โ”œโ”€โ”€ cli.py             # Typer CLI commands
โ”‚   โ”œโ”€โ”€ report.py          # rich output formatting
โ”‚   โ”œโ”€โ”€ web/               # FastAPI dashboard
โ”‚   โ””โ”€โ”€ utils.py           # helpers
โ”œโ”€โ”€ demo_tests/            # example test files
โ””โ”€โ”€ tests/                 # internal tests


๐Ÿ› ๏ธ Built With

Python pytest FastAPI SQLite Rich Typer


โš™๏ธ CI Integration

โœ… Includes a workflow: .github/workflows/pytest-enhanced.yml

Automatically:

  • runs tests with pytest --enhanced
  • exports analytics to CSV
  • uploads report as a GitHub Action artifact

View data in Actions โ†’ Artifacts.


๐Ÿ’ก Who Uses It?

  • QA engineers tracking flaky tests
  • Developers improving CI reliability
  • TestOps engineers building dashboards
  • Anyone tired of โ€œgreen == doneโ€ thinking

๐Ÿงญ Development Setup

git clone https://github.com/pgnikolov/pytest-enhanced.git
cd pytest-enhanced
pip install -e ".[dev]"
pytest --enhanced
pytest-enhanced report

๐Ÿงฉ Roadmap

  • CSV / JSON export command
  • GitHub Action for CI analytics
  • FastAPI-based web dashboard (beta)
  • HTML reports (rich โ†’ static)
  • Publish on PyPI

๐Ÿค Contributing

Contributions welcome! You can:

  • Submit pull requests
  • Propose new analytics features
  • Open issues or ideas

๐Ÿ“„ License

Licensed under the MIT License.


๐Ÿ’ฌ About

Created by Plamen Nikolov โ€” Python engineer, developer tooling enthusiast, and maker of things that improve test quality.


โšก โ€œYou canโ€™t fix what you donโ€™t measure โ€” pytest-enhanced helps you see the real picture.โ€