Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-103186: Make test_generated_cases less noisy by default
Print additional details only when tests are run with -vv.
  • Loading branch information
serhiy-storchaka committed Sep 7, 2023
commit 9eaf0cc9123f1949d1582c0f08b6da4eaacffe57
19 changes: 14 additions & 5 deletions Lib/test/test_generated_cases.py
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -12,6 +14,12 @@
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 = [
Expand Down Expand Up @@ -81,11 +89,12 @@ def run_cases_test(self, input: str, expected: str):
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()
Expand Down