Skip to content

Commit

Permalink
Python 3.11: Enhanced error locations in tracebacks (open-telemetry#2771
Browse files Browse the repository at this point in the history
)

* 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 <srikanth.chekuri92@gmail.com>
  • Loading branch information
hroncok and srikanthccv authored Jun 21, 2022
1 parent d4d7c67 commit aa36730
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions opentelemetry-sdk/tests/trace/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# pylint: disable=too-many-lines
import shutil
import subprocess
import sys
import unittest
from importlib import reload
from logging import ERROR, WARNING
Expand Down Expand Up @@ -1186,6 +1187,13 @@ def test_record_exception_context_manager(self):
stacktrace = """in test_record_exception_context_manager
raise RuntimeError("example error")
RuntimeError: example error"""
if sys.version_info >= (3, 11):
# https://docs.python.org/3.11/whatsnew/3.11.html#enhanced-error-locations-in-tracebacks
tracelines = stacktrace.splitlines()
tracelines.insert(
-1, " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
)
stacktrace = "\n".join(tracelines)
self.assertIn(stacktrace, event.attributes["exception.stacktrace"])

try:
Expand Down

0 comments on commit aa36730

Please sign in to comment.