From: Serhiy Storchaka Date: Thu, 7 Sep 2023 17:53:38 +0000 (+0300) Subject: gh-103186: Make test_generated_cases less noisy by default (GH-109100) X-Git-Tag: v3.13.0a1~551 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f9f085c326cdaa34ebb3ca018228a63825b12122;p=thirdparty%2FPython%2Fcpython.git gh-103186: Make test_generated_cases less noisy by default (GH-109100) Print additional details only when tests are run with -vv. --- diff --git a/Lib/test/test_generated_cases.py b/Lib/test/test_generated_cases.py index ed56f95af994..be3dfd204ee1 100644 --- a/Lib/test/test_generated_cases.py +++ b/Lib/test/test_generated_cases.py @@ -1,7 +1,9 @@ +import contextlib import tempfile import unittest import os +from test import support from test import test_tools test_tools.skip_if_missing('cases_generator') @@ -12,6 +14,12 @@ with test_tools.imports_under_tool('cases_generator'): from parsing import StackEffect +def handle_stderr(): + if support.verbose > 1: + return contextlib.nullcontext() + else: + return support.captured_stderr() + class TestEffects(unittest.TestCase): def test_effect_sizes(self): input_effects = [ @@ -81,11 +89,12 @@ class TestGeneratedCases(unittest.TestCase): temp_input.flush() a = generate_cases.Generator([self.temp_input_filename]) - a.parse() - a.analyze() - if a.errors: - raise RuntimeError(f"Found {a.errors} errors") - a.write_instructions(self.temp_output_filename, False) + with handle_stderr(): + a.parse() + a.analyze() + if a.errors: + raise RuntimeError(f"Found {a.errors} errors") + a.write_instructions(self.temp_output_filename, False) with open(self.temp_output_filename) as temp_output: lines = temp_output.readlines()