mirror of
https://github.com/bugsink/bugsink.git
synced 2025-12-30 18:00:17 -06:00
Add test for test_capture_or_log_exception
this test is assumed to surface problems on Python<3.10
This commit is contained in:
20
sentry_sdk_extensions/tests.py
Normal file
20
sentry_sdk_extensions/tests.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from unittest import TestCase
|
||||
import logging
|
||||
|
||||
from sentry_sdk_extensions import capture_or_log_exception
|
||||
|
||||
logger = logging.getLogger("test_logger")
|
||||
|
||||
|
||||
class SentrySDKExtensionsTest(TestCase):
|
||||
|
||||
def test_capture_or_log_exception(self):
|
||||
with self.assertLogs(logger='test_logger', level='ERROR') as test_logger_cm:
|
||||
try:
|
||||
raise Exception("I failed")
|
||||
except Exception as e:
|
||||
# in tests, the sentry SDK is off, so this tests the "or log exception" part of the test.
|
||||
capture_or_log_exception(e, logger)
|
||||
|
||||
self.assertTrue('ERROR:test_logger: raise Exception("I failed")' in test_logger_cm.output)
|
||||
self.assertTrue('ERROR:test_logger:Exception: I failed' in test_logger_cm.output)
|
||||
Reference in New Issue
Block a user