Skip to main content

A pytest plugin for sending test results to Slack and Telegram

Project description

pytest-alerts

A pytest plugin that sends test results to Slack and Telegram with beautiful, customizable formatting.

PyPI version Python Versions Downloads

Overview

pytest-alerts is a powerful pytest plugin that automatically sends your test results to Slack and Telegram. It provides:

  • 📲 Real-time test notifications to Slack and Telegram
  • 🎨 Modern, visually appealing message formatting
  • 📊 Comprehensive test statistics with progress bars
  • 🔍 Configurable error reporting and details
  • ⚙️ Extensive customization options
  • 🔄 Full compatibility with pytest-xdist

Quick Start

Installation

pip install pytest-alerts

Basic Usage

  1. Configure your messaging platform:

    For Slack:

    pytest --slack_webhook=YOUR_WEBHOOK_URL
    

    For Telegram:

    pytest --telegram_token=BOT_TOKEN --telegram_chat_id=CHAT_ID
    
  2. Run with both platforms:

    pytest --slack_webhook=URL --telegram_token=TOKEN --telegram_chat_id=ID
    

Configuration Options

Common Options

Option Description Default
--show_details Include error details in notifications False
--hide_errors Hide error messages from notifications False

Slack-specific Options

Option Description Required
--slack_webhook Slack webhook URL Yes
--slack_channel Override default channel No
--slack_username Bot username No
--slack_icon Bot icon emoji No

Telegram-specific Options

Option Description Required
--telegram_token Bot API token Yes
--telegram_chat_id Target chat ID Yes
--telegram_thread_id Specific thread ID No

Message Formatting

Default Format

Messages include:

  • Test run summary (passed/failed/skipped)
  • Progress bars for visual representation
  • Duration of test run
  • Error details (if enabled)
  • Project/branch information (if available)

Customization

  • Use --show_details for full error traces
  • Use --hide_errors to omit error messages
  • Platform-specific formatting options available

Advanced Usage

Environment Variables

Configure using environment variables:

export PYTEST_ALERTS_SLACK_WEBHOOK="your-webhook-url"
export PYTEST_ALERTS_TELEGRAM_TOKEN="your-bot-token"
export PYTEST_ALERTS_TELEGRAM_CHAT_ID="your-chat-id"

CI/CD Integration

Example GitHub Actions workflow:

steps:
  - uses: actions/checkout@v2
  - name: Run tests with notifications
    env:
      PYTEST_ALERTS_SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
    run: |
      pip install pytest-alerts
      pytest --slack_webhook=$PYTEST_ALERTS_SLACK_WEBHOOK

Limitations

  • Maximum message size varies by platform
  • Rate limits apply (platform-specific)
  • Some formatting options are platform-dependent

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

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

Support

Changelog

See CHANGELOG.md for version history and changes.

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_alerts-1.1.0.tar.gz (7.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_alerts-1.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest_alerts-1.1.0.tar.gz.

File metadata

  • Download URL: pytest_alerts-1.1.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.10

File hashes

Hashes for pytest_alerts-1.1.0.tar.gz
Algorithm Hash digest
SHA256 05c8d72524dc96b7999af63d2bc8bbbfbf1ae60bb0ee07a5633eb9cb92e88362
MD5 0001df553b8ee3285b0ffc0b596a9071
BLAKE2b-256 7f76983cf39bd14574f3ecbc95aab94c56e43ca3bfa8cfa68ca72b81b0862a28

See more details on using hashes here.

File details

Details for the file pytest_alerts-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_alerts-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.10

File hashes

Hashes for pytest_alerts-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65fd81fecf764aab8e09f5a119cc4c800fe586df33020a1ca4fba87f680c1910
MD5 a9085beaa2c4c63d39281894de5f0776
BLAKE2b-256 47e4ac49cefb40ee1710cddd0ff3090b780e4b89e99bf6742728726d8c6da4b5

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