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.
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
-
Configure your messaging platform:
For Slack:
pytest --slack_webhook=YOUR_WEBHOOK_URL
For Telegram:
pytest --telegram_bot_token=BOT_TOKEN --telegram_chat_id=CHAT_ID
-
Run with both platforms:
pytest --slack_webhook=URL --telegram_bot_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_icon |
Bot icon emoji | No |
Telegram-specific Options
| Option | Description | Required |
|---|---|---|
--telegram_bot_token |
Bot API token | Yes |
--telegram_chat_id |
Target chat ID | Yes |
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_detailsfor full error traces - Use
--hide_errorsto omit error messages - Platform-specific formatting options available
Advanced Usage
CI/CD Integration
Example GitHub Actions workflow:
steps:
- uses: actions/checkout@v2
- name: Run tests with notifications
run: |
pip install pytest-alerts
pytest --slack_webhook=${{ secrets.SLACK_WEBHOOK }} --telegram_bot_token=${{ secrets.TELEGRAM_BOT_TOKEN }} --telegram_chat_id=${{ secrets.TELEGRAM_CHAT_ID }}
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_alerts-1.4.0.tar.gz.
File metadata
- Download URL: pytest_alerts-1.4.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80e0ef469e55823db5af1fb8559f283b7edccef7b80b75fa8c1e7da2b45c04b2
|
|
| MD5 |
c533b1eb9416d871ace66ab74a4ed31e
|
|
| BLAKE2b-256 |
e618637be786c1b210f34051c589ee53e10438549bc10069a4165aee14b2f538
|
File details
Details for the file pytest_alerts-1.4.0-py3-none-any.whl.
File metadata
- Download URL: pytest_alerts-1.4.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b14b93302c292c7a9ee1bd4d64c9a48d04cb392ce6052079805833aafb132b1c
|
|
| MD5 |
a19d0f2d34a0684146b794dab0770c9b
|
|
| BLAKE2b-256 |
ab8a0003f7f6b0e58aa71e215165487d5b4c77ebdb84a88d07568d62c0e6030e
|