From 0b971a1aef2fa27574d3c7c5f1a8a2eed6c2c1ec Mon Sep 17 00:00:00 2001 From: Danny McClanahan <1305167+cosmicexplorer@users.noreply.github.com> Date: Mon, 24 Oct 2022 13:08:18 -0400 Subject: redact line numbers from grouped exception message (#33485) --- lib/spack/spack/test/llnl/util/lang.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/test/llnl/util/lang.py b/lib/spack/spack/test/llnl/util/lang.py index bced121136..63090caa38 100644 --- a/lib/spack/spack/test/llnl/util/lang.py +++ b/lib/spack/spack/test/llnl/util/lang.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os.path +import re import sys from datetime import datetime, timedelta from textwrap import dedent @@ -307,22 +308,25 @@ def test_grouped_exception(): top-level raised TypeError: ok""" ) + full_message = h.grouped_message(with_tracebacks=True) + no_line_numbers = re.sub(r"line [0-9]+,", "line xxx,", full_message) + assert ( - h.grouped_message(with_tracebacks=True) + no_line_numbers == dedent( """\ due to the following failures: inner method raised ValueError: wow! File "{0}", \ -line 298, in test_grouped_exception +line xxx, in test_grouped_exception inner() File "{0}", \ -line 295, in inner +line xxx, in inner raise ValueError("wow!") top-level raised TypeError: ok File "{0}", \ -line 301, in test_grouped_exception +line xxx, in test_grouped_exception raise TypeError("ok") """ ).format(__file__) -- cgit v1.2.3-60-g2f50