Skip to content

gh-103186: Make test_generated_cases less noisy by default #109100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
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