Skip to main content

A tool to analyze pytest test files and generate reports

Project description

pytest-test-analyzer

A powerful Python tool that analyzes pytest test files and generates comprehensive reports. Get deep insights into your test suite by analyzing test structure, decorator patterns, and test organization. Perfect for understanding and maintaining large test suites, tracking test coverage patterns, and identifying areas for test optimization.

Features

  • 🔍 Analyzes pytest test files and directories
  • 📊 Generates detailed statistics about test cases
  • 🏷️ Tracks pytest markers and decorators
  • 📝 Supports multiple output formats (HTML, Markdown, Text)
  • 🎯 Filter tests by decorators
  • 📈 Provides class-wise and marker-wise statistics
  • 🎨 Beautiful HTML reports with charts

Installation

pip install pytest-test-analyzer

Usage

Basic Usage

Analyze a test directory and generate an HTML report:

pytest-test-analyzer --path "path/to/tests" --output report.html --format html

Command Line Options

pytest-test-analyzer --path PATH [--output OUTPUT] [--format FORMAT] [--include INCLUDE] [--exclude EXCLUDE]
  • --path: Path(s) to Python test files or directories (required)
  • --output: Output file path
  • --format: Output format - txt, html, or md (default: html)
  • --include: Include only tests with specific decorators
  • --exclude: Exclude tests with specific decorators

Examples

Analyzing Test Files

  1. Analyze a single test file:

    pytest-test-analyzer --path "tests/test_login.py" --output login_analysis.html --format html
    
  2. Analyze multiple specific test files:

    pytest-test-analyzer --path "tests/test_login.py" "tests/test_registration.py" --output auth_analysis.html
    
  3. Analyze test files with specific patterns:

    pytest-test-analyzer --path "tests/test_*_api.py" --output api_analysis.html
    

Analyzing Test Directories

  1. Analyze a single test directory:

    pytest-test-analyzer --path ./tests --output report.html --format html
    
  2. Analyze multiple test directories:

    pytest-test-analyzer --path ./tests ./integration_tests --output report.html
    
  3. Analyze nested test directories:

    pytest-test-analyzer --path ./tests/unit ./tests/integration --output nested_analysis.html
    

Filtering Tests

  1. Include only tests with specific decorators:

    pytest-test-analyzer --path ./tests --include pytest.mark.sanity pytest.mark.regression
    
  2. Exclude tests with specific decorators:

    pytest-test-analyzer --path ./tests --exclude pytest.mark.skip pytest.mark.xfail
    
  3. Combine file and decorator filters:

    pytest-test-analyzer --path "tests/test_api.py" --include pytest.mark.smoke --output api_smoke.html
    

Output Formats

  1. Generate a markdown report:

    pytest-test-analyzer --path ./tests --output report.md --format md
    
  2. Generate a text report:

    pytest-test-analyzer --path ./tests --output report.txt --format txt
    
  3. Generate HTML report with custom name:

    pytest-test-analyzer --path ./tests --output custom_name.html --format html
    

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions, please open an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_test_analyzer-0.1.0.tar.gz (35.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_test_analyzer-0.1.0-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_test_analyzer-0.1.0.tar.gz.

File metadata

  • Download URL: pytest_test_analyzer-0.1.0.tar.gz
  • Upload date:
  • Size: 35.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pytest_test_analyzer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 58b13641dd3598496d66a5659cbe090be418fe1645b7a3ad5e9a1b4eb5d0fe0b
MD5 df0bb575c7df5fde8c7a33c940c0e4c3
BLAKE2b-256 81861b8fec55809d22dcafdfb33c951b7b837bd9735ae6118808773f886edff9

See more details on using hashes here.

File details

Details for the file pytest_test_analyzer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_test_analyzer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65fd330e8ae4369f064bd98ebddb3e9090a83b02bb4a9cc51050cf719d506988
MD5 7962972aae35b64c292114af3183a0f7
BLAKE2b-256 f950ab57fca0c86565f884eecb696cdd21aa932296b088d270123c68d9d5c644

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page