From aa367302989978a1ae04badee7e3948502b96616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 21 Jun 2022 12:45:59 +0200 Subject: [PATCH] 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 --- opentelemetry-sdk/tests/trace/test_trace.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/opentelemetry-sdk/tests/trace/test_trace.py b/opentelemetry-sdk/tests/trace/test_trace.py index b89734db2f..890ae3e1e2 100644 --- a/opentelemetry-sdk/tests/trace/test_trace.py +++ b/opentelemetry-sdk/tests/trace/test_trace.py @@ -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 @@ -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: