Skip to content

Commit aa36730

Browse files
hroncoksrikanthccv
andauthored
Python 3.11: Enhanced error locations in tracebacks (#2771)
* Python 3.11: Enhanced error locations in tracebacks Expect ^^^^^^^^^ in tracebacks when testing them * Update opentelemetry-sdk/tests/trace/test_trace.py Co-authored-by: Srikanth Chekuri <[email protected]>
1 parent d4d7c67 commit aa36730

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

opentelemetry-sdk/tests/trace/test_trace.py

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# pylint: disable=too-many-lines
1616
import shutil
1717
import subprocess
18+
import sys
1819
import unittest
1920
from importlib import reload
2021
from logging import ERROR, WARNING
@@ -1186,6 +1187,13 @@ def test_record_exception_context_manager(self):
11861187
stacktrace = """in test_record_exception_context_manager
11871188
raise RuntimeError("example error")
11881189
RuntimeError: example error"""
1190+
if sys.version_info >= (3, 11):
1191+
# https://docs.python.org/3.11/whatsnew/3.11.html#enhanced-error-locations-in-tracebacks
1192+
tracelines = stacktrace.splitlines()
1193+
tracelines.insert(
1194+
-1, " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
1195+
)
1196+
stacktrace = "\n".join(tracelines)
11891197
self.assertIn(stacktrace, event.attributes["exception.stacktrace"])
11901198

11911199
try:

0 commit comments

Comments
 (0)