Skip to content

Commit

Permalink
Clear session tracker state between test cases
Browse files Browse the repository at this point in the history
This isn't _necessary_ to have the tests run, but not doing so causes
any outstanding sessions to fail delivery after the server is torn down,
which leads to a bunch of warnings
  • Loading branch information
imjoehaines committed Dec 7, 2023
1 parent 08f9c90 commit d54f693
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion tests/integrations/test_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class SentinelError(RuntimeError):


class TestWSGI(IntegrationTest):

def setUp(self):
super(TestWSGI, self).setUp()
bugsnag.configure(
Expand Down
14 changes: 11 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ def setUp(self):
self.server.sessions_received = []

def tearDown(self):
bugsnag.legacy.default_client.uninstall_sys_hook()
client = bugsnag.Client()
client.configuration.api_key = 'some key'
previous_client = bugsnag.legacy.default_client
previous_client.uninstall_sys_hook()

if previous_client.session_tracker.delivery_thread is not None:
previous_client.session_tracker.delivery_thread.cancel()
previous_client.session_tracker.delivery_thread = None

previous_client.session_tracker.session_counts = {}

client = bugsnag.Client(api_key='some key')

bugsnag.legacy.default_client = client
bugsnag.legacy.configuration = client.configuration

Expand Down

0 comments on commit d54f693

Please sign in to comment.