{"id":3243,"library":"pytest-messenger","title":"Pytest Messenger","description":"pytest-messenger is a pytest plugin for sending test execution reports to various instant messaging platforms, including Slack, DingTalk, and Telegram. It streamlines communication for CI/CD pipelines and development teams by providing automated notifications of test outcomes. The library is actively maintained, with the current version being 3.3.0, and receives updates periodically.","status":"active","version":"3.3.0","language":"en","source_language":"en","source_url":"https://github.com/pytest-dev/pytest-messenger","tags":["pytest","testing","notifications","slack","dingtalk","telegram","ci/cd"],"install":[{"cmd":"pip install pytest-messenger","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core testing framework that this plugin extends.","package":"pytest","optional":false},{"reason":"Used for making HTTP requests to messenger APIs (e.g., Slack webhooks, Telegram Bot API).","package":"requests","optional":false}],"imports":[],"quickstart":{"code":"import os\nimport pytest\n\n# To simulate a test run and trigger reporting\ndef test_example_success():\n    assert True\n\ndef test_example_failure():\n    assert False\n\n# To run this example:\n# 1. Create a virtual environment and install pytest-messenger:\n#    pip install pytest-messenger pytest\n# 2. Set your Slack webhook URL as an environment variable:\n#    export SLACK_WEBHOOK_URL='https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'\n# 3. (Optional) Set a Slack channel and username:\n#    export SLACK_CHANNEL='#test-reports'\n#    export SLACK_USERNAME='CI Bot'\n# 4. Save the above Python code as a test file (e.g., test_report.py).\n# 5. Run pytest with the plugin options (values are pulled from env vars):\n#    pytest test_report.py \\\n#        --slack_hook=\"${SLACK_WEBHOOK_URL}\" \\\n#        --slack_channel=\"${SLACK_CHANNEL:-#general}\" \\\n#        --slack_username=\"${SLACK_USERNAME:-Pytest Report}\"\n","lang":"bash","description":"To quickly get started with pytest-messenger, you typically configure it via command-line options or a `pytest.ini` file. This example demonstrates how to run pytest and report results to Slack using environment variables for sensitive data. Ensure your Slack webhook URL is correctly configured and accessible."},"warnings":[{"fix":"Uninstall `pytest-slack` (if present) and `pip install pytest-messenger`. Review the new documentation for specific command-line argument and `pytest.ini` key changes if you encounter issues.","message":"In version 3.0.0, the package was renamed from `pytest-slack` to `pytest-messenger` to reflect support for multiple messaging platforms (Slack, DingTalk, Telegram). If upgrading from an older version (pre-3.0.0) that used `pytest-slack`, you must uninstall the old package and install `pytest-messenger`. Command-line arguments and configuration options might also have minor changes.","severity":"breaking","affected_versions":"<3.0.0"},{"fix":"Pass sensitive data via environment variables (e.g., `os.environ.get('SLACK_WEBHOOK_URL')`) and reference them in your `pytest` command or `pytest.ini` configuration. For example, `--slack_hook='${SLACK_WEBHOOK_URL}'`.","message":"Sensitive information like webhook URLs and API tokens should not be hardcoded in your test files or version-controlled configuration files. Always use environment variables, a secrets management system, or a `pytest.ini` file with appropriate access controls.","severity":"gotcha","affected_versions":"All"},{"fix":"Verify the webhook URL/token directly with your messenger platform's integration settings. Ensure it's active and correctly copied. Check the pytest output for any plugin-specific error messages that might indicate an issue with the API call.","message":"If reports are not being sent, check that the provided webhook URL or API token (for Slack, DingTalk, Telegram) is correct and has the necessary permissions in your messenger application. Incorrect credentials often lead to silent failures where no report is posted.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}