Pytest Slack Reporting Plugin

2.3.1 · abandoned · verified Thu Apr 16

pytest-slack is a pytest plugin designed to send test execution reports directly to Slack. While it provided basic reporting, development on this package ceased after version 2.3.1 (December 2020). The project has since been renamed and continued as `pytest-messenger`, which offers broader messaging support including Slack, DingTalk, and Telegram. Users seeking active development and new features should use `pytest-messenger` instead.

Common errors

Warnings

Install

Quickstart

The plugin is configured via command-line arguments when running `pytest`. It is recommended to use environment variables for sensitive information like Slack webhook URLs, especially in CI/CD environments. Create a test file, then run pytest with the necessary arguments to specify the Slack webhook, channel, and optionally a username.

# Save this in a test file (e.g., test_example.py)
def test_passing():
    assert True

def test_failing():
    assert False

# To run and report to Slack:
# Set your Slack webhook URL as an environment variable or pass directly
# Example using environment variable:
# export SLACK_HOOK='https://hooks.slack.com/services/TXXXXXXXX/BXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXX'
# pytest --slack_hook=$SLACK_HOOK --slack_channel='#test-reports' --slack_username='Pytest Bot'
# For local testing without environment variables (less secure for CI/CD):
# pytest --slack_hook='https://hooks.slack.com/services/TXXXXXXXX/BXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXX' --slack_channel='#test-reports' --slack_username='Pytest Bot'

view raw JSON →