Skip to content

Commit f9f085c

Browse files
gh-103186: Make test_generated_cases less noisy by default (GH-109100)
Print additional details only when tests are run with -vv.
1 parent 9639696 commit f9f085c

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Lib/test/test_generated_cases.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import contextlib
12
import tempfile
23
import unittest
34
import os
45

6+
from test import support
57
from test import test_tools
68

79
test_tools.skip_if_missing('cases_generator')
@@ -12,6 +14,12 @@
1214
from parsing import StackEffect
1315

1416

17+
def handle_stderr():
18+
if support.verbose > 1:
19+
return contextlib.nullcontext()
20+
else:
21+
return support.captured_stderr()
22+
1523
class TestEffects(unittest.TestCase):
1624
def test_effect_sizes(self):
1725
input_effects = [
@@ -81,11 +89,12 @@ def run_cases_test(self, input: str, expected: str):
8189
temp_input.flush()
8290

8391
a = generate_cases.Generator([self.temp_input_filename])
84-
a.parse()
85-
a.analyze()
86-
if a.errors:
87-
raise RuntimeError(f"Found {a.errors} errors")
88-
a.write_instructions(self.temp_output_filename, False)
92+
with handle_stderr():
93+
a.parse()
94+
a.analyze()
95+
if a.errors:
96+
raise RuntimeError(f"Found {a.errors} errors")
97+
a.write_instructions(self.temp_output_filename, False)
8998

9099
with open(self.temp_output_filename) as temp_output:
91100
lines = temp_output.readlines()

0 commit comments

Comments
 (0)