-
Notifications
You must be signed in to change notification settings - Fork 536
/
Copy pathconftest.py
34 lines (27 loc) · 1.13 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pytest
import sentry_sdk
@pytest.fixture
def capture_exceptions(monkeypatch):
def inner():
errors = set()
old_capture_event_hub = sentry_sdk.Hub.capture_event
old_capture_event_scope = sentry_sdk.Scope.capture_event
def capture_event_hub(self, event, hint=None, scope=None):
"""
Can be removed when we remove push_scope and the Hub from the SDK.
"""
if hint:
if "exc_info" in hint:
error = hint["exc_info"][1]
errors.add(error)
return old_capture_event_hub(self, event, hint=hint, scope=scope)
def capture_event_scope(self, event, hint=None, scope=None):
if hint:
if "exc_info" in hint:
error = hint["exc_info"][1]
errors.add(error)
return old_capture_event_scope(self, event, hint=hint, scope=scope)
monkeypatch.setattr(sentry_sdk.Hub, "capture_event", capture_event_hub)
monkeypatch.setattr(sentry_sdk.Scope, "capture_event", capture_event_scope)
return errors
return inner