Skip to content

Commit

Permalink
[FIX] sentry: test failure due to incomplete transport init
Browse files Browse the repository at this point in the history
The test code uses a "mock" Transport object to ensure that events are
stored locally in memory, instead of triggering network requests.

The Sentry client is cleaned up once done, and this triggers a call to
capture_envelope, a different way of sending events to Sentry. Since
our mock class did not fully complete initialization, and also did
not provide an overriding method, the original was called, which
depends on proper initialization to work.

We introduce an override for capture_envelope: as it is meant to be
a "sibling" to capture_event, it makes sense for us to also make sure
events registrered in this way are intercepted, even if we don't
currently expect any of our tests to explicitly cause it to be used.
  • Loading branch information
aisopuro committed Oct 20, 2022
1 parent 3f7616f commit ced4efc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sentry/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ class InMemoryTransport(HttpTransport):

def __init__(self, *args, **kwargs):
self.events = []
self.envelopes = []

def capture_event(self, event, *args, **kwargs):
self.events.append(event)

def capture_envelope(self, envelope, *args, **kwargs):
self.envelopes.append(envelope)

def has_event(self, event_level, event_msg):
for event in self.events:
if (
Expand Down

0 comments on commit ced4efc

Please sign in to comment.