]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-136438: Make sure `test_generated_cases` pass with all optimization levels (#136594)
authorMikhail Efimov <efimov.mikhail@gmail.com>
Mon, 21 Jul 2025 12:25:25 +0000 (15:25 +0300)
committerGitHub <noreply@github.com>
Mon, 21 Jul 2025 12:25:25 +0000 (15:25 +0300)
commit58d305cf387816c559602a95ba850856dc9b8129
tree8cc0a2aa32dbbfae838c87d95ad01542a66cc524
parent658599c15d13ee3a5cb56c3d9fccaa195465d4b5
gh-136438: Make sure `test_generated_cases` pass with all optimization levels (#136594)

Fix the `test_generated_cases` to work with `-O` or `-OO` flags.
Previously, `test_generated_cases` was catching an `AssertionError` while `Tools/cases_generator/optimizer_generator.py` used an `assert` statement.  This approach semantically incorrect, no one should trying to catch an `AssertionError`!
Now the `assert` statement has been replaced with an explicit `raise ValueError(...)` and the corresponding `self.assertRaisesRegex(AssertionError, ...)` has been updated to catch a `ValueError` instead.
Lib/test/test_generated_cases.py
Tools/cases_generator/optimizer_generator.py