A pytest plugin that sends test results to Slack and Telegram with beautiful, customizable formatting.
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
pip install pytest-alerts-
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
| Option | Description | Default |
|---|---|---|
--show_details |
Include error details in notifications | False |
--hide_errors |
Hide error messages from notifications | False |
| Option | Description | Required |
|---|---|---|
--slack_webhook |
Slack webhook URL | Yes |
--slack_icon |
Bot icon emoji | No |
| Option | Description | Required |
|---|---|---|
--telegram_bot_token |
Bot API token | Yes |
--telegram_chat_id |
Target chat ID | Yes |
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)
- Use
--show_detailsfor full error traces - Use
--hide_errorsto omit error messages - Platform-specific formatting options available
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 }}- Maximum message size varies by platform
- Rate limits apply (platform-specific)
- Some formatting options are platform-dependent
We welcome contributions! Please see our Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for version history and changes.