pytest-sentry
raw JSON → 0.5.1 verified Fri May 01 auth: no python
A pytest plugin to send test run information to Sentry.io. Currently at version 0.5.1, with irregular releases. Compatible with Sentry SDK >=3.0 (since 0.4.0).
pip install pytest-sentry Common errors
error ImportError: cannot import name 'hub' from 'pytest_sentry' ↓
cause pytest_sentry.hub was removed in newer versions; use sentry_sdk directly.
fix
Use 'import sentry_sdk; sentry_sdk.init()' instead of 'pytest_sentry.hub.init()'.
error Sentry could not send events: You need a DSN to send events (DSN not set) ↓
cause SENTRY_DSN environment variable is not set or empty.
fix
Set environment variable SENTRY_DSN or pass it via pytest ini option: '--sentry-dsn=...'
error TypeError: Client.__init__() got an unexpected keyword argument 'integrations' ↓
cause Mismatched sentry-sdk version; sentry-sdk <2.0 does not support certain arguments used by pytest-sentry >=0.3.0.
fix
Upgrade sentry-sdk to >=2.0.0 (or >=3.0.0 for pytest-sentry >=0.4.0).
Warnings
breaking Version 0.4.0+ requires sentry-sdk >=3.0. Older sentry-sdk versions will break. ↓
fix Upgrade sentry-sdk to >=3.0.0: pip install -U sentry-sdk
breaking Version 0.3.x requires sentry-sdk >=2.0. sentry-sdk<2.0 will break. ↓
fix Use pytest-sentry 0.1.16 with sentry-sdk <2.0, or upgrade sentry-sdk.
deprecated The 'hub' object is deprecated in favor of direct Sentry SDK usage. Consider using sentry_sdk directly. ↓
fix Replace pytest_sentry.hub with sentry_sdk: 'import sentry_sdk; sentry_sdk.init(...)'
Imports
- pytest_sentry
import pytest_sentry
Quickstart
# conftest.py
import pytest_sentry
SENTRY_DSN = os.environ.get('SENTRY_DSN', '')
@pytest.fixture(autouse=True)
def sentry_test_hub():
pytest_sentry.hub.init(dsn=SENTRY_DSN)
yield