def test_merging(sentry_init, capture_events): sentry_init() s = Scope() s.set_user({"id": 42}) events = capture_events() capture_exception(NameError(), scope=s) (event,) = events assert event["user"] == {"id": 42}
def inner(): # type: () -> Generator[Scope, None, None] if client is not None: yield scope else: print("I am yielding Scope()") yield Scope()
def __init__(self, client_or_hub=None, scope=None): if isinstance(client_or_hub, Hub): hub = client_or_hub client, other_scope = hub._stack[-1] if scope is None: scope = copy.copy(other_scope) else: client = client_or_hub if scope is None: scope = Scope() self._stack = [(client, scope)] self._last_event_id = None self._old_hubs = []
def test_copying(): s1 = Scope() s1.fingerprint = {} s1.set_tag("foo", "bar") s2 = copy.copy(s1) assert "foo" in s2._tags s1.set_tag("bam", "baz") assert "bam" in s1._tags assert "bam" not in s2._tags assert s1._fingerprint is s2._fingerprint
def __init__(self, client_or_hub=None, scope=None): # type: (Optional[Union[Hub, Client]], Optional[Any]) -> None if isinstance(client_or_hub, Hub): hub = client_or_hub client, other_scope = hub._stack[-1] if scope is None: scope = copy.copy(other_scope) else: client = client_or_hub if scope is None: scope = Scope() self._stack = [(client, scope)] self._last_event_id = None # type: Optional[str] self._old_hubs = [] # type: List[Hub]
def inner(): # type: () -> Generator[Scope, None, None] if client is not None: yield scope else: yield Scope()
def inner(): if client is not None: yield scope else: yield Scope()
def inner(): yield Scope()
def __enter__(self): scope = self._layer[1] if scope is None: scope = Scope() return scope
def test_common_args(): s = Scope() s.update_from_kwargs( user={"id": 23}, level="warning", extras={"k": "v"}, contexts={"os": {"name": "Blafasel"}}, tags={"x": "y"}, fingerprint=["foo"], ) s2 = Scope() s2.set_extra("foo", "bar") s2.set_tag("a", "b") s2.set_context("device", {"a": "b"}) s2.update_from_scope(s) assert s._user == {"id": 23} assert s._level == "warning" assert s._extras == {"k": "v"} assert s._contexts == {"os": {"name": "Blafasel"}} assert s._tags == {"x": "y"} assert s._fingerprint == ["foo"] assert s._user == s2._user assert s._level == s2._level assert s._fingerprint == s2._fingerprint assert s2._extras == {"k": "v", "foo": "bar"} assert s2._tags == {"a": "b", "x": "y"} assert s2._contexts == {"os": {"name": "Blafasel"}, "device": {"a": "b"}}