Skip to content
Snippets Groups Projects
Commit e25a2f4e authored by Antoine Lambert's avatar Antoine Lambert
Browse files

tests/conftest: Remove sentry fixtures

They have been moved in a swh-core pytest plugin to share them with
other swh packages that might need it.
parent 6d7efad9
No related branches found
No related tags found
1 merge request!389tests/conftest: Remove sentry fixtures
swh.core[db,http] >= 2.9
swh.core[db,http] >= 2.14.1
swh.model >= 0.0.15
swh.objstorage >= 0.2.2
swh.scheduler >= 0.5.2
......
......@@ -11,7 +11,6 @@ from unittest.mock import patch
import pytest
from pytest_postgresql import factories
import sentry_sdk
import yaml
from swh.core.db.pytest_plugin import initialize_database_for_module
......@@ -131,40 +130,3 @@ def swh_config(swh_indexer_config, monkeypatch, tmp_path):
f.write(yaml.dump(swh_indexer_config))
monkeypatch.setenv("SWH_CONFIG_FILENAME", conffile)
return conffile
@pytest.fixture
def sentry_init():
# Inspired by
# https://github.com/getsentry/sentry-python/blob/1.5.9/tests/conftest.py#L168-L184
initialized = False
def inner(*a, **kw):
nonlocal initialized
assert not initialized, "already initialized"
initialized = True
hub = sentry_sdk.Hub.current
client = sentry_sdk.Client(*a, **kw)
hub.bind_client(client)
client.transport = TestTransport()
class TestTransport:
def __init__(self):
self.events = []
self.envelopes = []
def capture_event(self, event):
self.events.append(event)
def capture_envelope(self, envelope):
self.envelopes.append(envelope)
with sentry_sdk.Hub(None):
yield inner
@pytest.fixture
def sentry_events(monkeypatch, sentry_init):
sentry_init()
return sentry_sdk.Hub.current.client.transport.events
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment