gh-103186: Make test_generated_cases less noisy by default (GH-109100)

Print additional details only when tests are run with -vv.
This commit is contained in:
Serhiy Storchaka 2023-09-07 20:53:38 +03:00 committed by GitHub
parent 96396962ce
commit f9f085c326
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 5 deletions

View File

@ -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()