Skip to content

Commit 93d69eb

Browse files
committed
Simplify test
1 parent 2f9417a commit 93d69eb

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

opentelemetry-sdk/tests/logs/test_handler.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,12 @@ def test_log_exc_info_false(self):
230230
def test_log_record_exception_with_object_payload(self):
231231
processor, logger = set_up_test_logging(logging.ERROR)
232232

233-
class CustomObject:
234-
pass
235-
236233
class CustomException(Exception):
237-
def __init__(self, data):
238-
self.data = data
239-
240234
def __str__(self):
241235
return "CustomException stringified"
242236

243237
try:
244-
raise CustomException(CustomObject())
238+
raise CustomException("CustomException message")
245239
except CustomException as exception:
246240
with self.assertLogs(level=logging.ERROR):
247241
logger.exception(exception)
@@ -255,17 +249,16 @@ def __str__(self):
255249
log_record.attributes[SpanAttributes.EXCEPTION_TYPE],
256250
CustomException.__name__,
257251
)
258-
self.assertTrue(
259-
"<tests.logs.test_handler.TestLoggingHandler.test_log_record_exception_with_object_payload.<locals>.CustomObject"
260-
in log_record.attributes[SpanAttributes.EXCEPTION_MESSAGE]
252+
self.assertEqual(
253+
log_record.attributes[SpanAttributes.EXCEPTION_MESSAGE],
254+
"CustomException message",
261255
)
262256
stack_trace = log_record.attributes[
263257
SpanAttributes.EXCEPTION_STACKTRACE
264258
]
265259
self.assertIsInstance(stack_trace, str)
266260
self.assertTrue("Traceback" in stack_trace)
267261
self.assertTrue("CustomException" in stack_trace)
268-
self.assertTrue("CustomObject" in stack_trace)
269262
self.assertTrue(__file__ in stack_trace)
270263

271264
def test_log_record_trace_correlation(self):

0 commit comments

Comments
 (0)