diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-09-07 17:53:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-07 17:53:38 (GMT) |
commit | f9f085c326cdaa34ebb3ca018228a63825b12122 (patch) | |
tree | d063f27d13ab899b79dc0a0992811eebe34915db | |
parent | 96396962ce7a83c09bac5061121c779ca6b25ef5 (diff) | |
download | cpython-f9f085c326cdaa34ebb3ca018228a63825b12122.zip cpython-f9f085c326cdaa34ebb3ca018228a63825b12122.tar.gz cpython-f9f085c326cdaa34ebb3ca018228a63825b12122.tar.bz2 |
gh-103186: Make test_generated_cases less noisy by default (GH-109100)
Print additional details only when tests are run with -vv.
-rw-r--r-- | Lib/test/test_generated_cases.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Lib/test/test_generated_cases.py b/Lib/test/test_generated_cases.py index ed56f95..be3dfd2 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() |