]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-136438: Make sure `test_builtins` pass with all optimization levels (#136474)
authorsobolevn <mail@sobolevn.me>
Thu, 10 Jul 2025 08:57:29 +0000 (11:57 +0300)
committerGitHub <noreply@github.com>
Thu, 10 Jul 2025 08:57:29 +0000 (11:57 +0300)
Lib/test/test_builtin.py

index 14fe335523961542be036b3161833dbd7dd59044..8830641f0abdc79048665f2308d7fa7a8a81d32f 100644 (file)
@@ -436,7 +436,7 @@ class BuiltinTest(ComplexesAreIdenticalMixin, unittest.TestCase):
             # test both direct compilation and compilation via AST
                 codeobjs = []
                 codeobjs.append(compile(codestr, "<test>", "exec", optimize=optval))
-                tree = ast.parse(codestr)
+                tree = ast.parse(codestr, optimize=optval)
                 codeobjs.append(compile(tree, "<test>", "exec", optimize=optval))
                 for code in codeobjs:
                     ns = {}
@@ -624,7 +624,7 @@ class BuiltinTest(ComplexesAreIdenticalMixin, unittest.TestCase):
         for opt in [opt1, opt2]:
             opt_right = opt.value.right
             self.assertIsInstance(opt_right, ast.Constant)
-            self.assertEqual(opt_right.value, True)
+            self.assertEqual(opt_right.value, __debug__)
 
     def test_delattr(self):
         sys.spam = 1