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.
Metadata
Release files for pytest-alerts 1.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_alerts-1.6.1.tar.gz | 7.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_alerts-1.6.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.9 kB
Release files / pytest_alerts-1.6.1.tar.gz
| Download URL | pytest_alerts-1.6.1.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b23240f3b08737d651672bd25af238373115466364cf9a8903e6ab845915a21e
|
|
BLAKE2b-256 checksum How to use checksums |
fc6ce7cdc23a1ec5d93b6e0b866d17a8ee1dc3e17eb07185b340960c49ed1123
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|
Release files / pytest_alerts-1.6.1-py3-none-any.whl
| Download URL | pytest_alerts-1.6.1-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7029ed5f442e88953c02f53c25651f1515ee7cd80459afab4f1da8ffc442c29
|
|
BLAKE2b-256 checksum How to use checksums |
b6b94470cb8098f1377ea14466be6ec8e1e9def62b5025cc811e4e94c58427b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|