diff --git a/Lib/test/test_ast/test_ast.py b/Lib/test/test_ast/test_ast.py index 095bc5832f6aca6..45e953dfe0a7132 100644 --- a/Lib/test/test_ast/test_ast.py +++ b/Lib/test/test_ast/test_ast.py @@ -25,6 +25,7 @@ _testinternalcapi = None from test import support +from test.support import isolation from test.support import os_helper from test.support import (skip_emscripten_stack_overflow, skip_wasi_stack_overflow, @@ -104,6 +105,10 @@ def test_AST_objects(self): ast.AST(2) @unittest.skipIf(_testinternalcapi is None, "requires _testinternalcapi") + # gh-161354: Run the test in a subprocess to make it more deterministic. + # Inline values depend on Constant_type.ht_cached_keys which changes when + # ast.Constant instances are created, so they depend on other run tests. + @isolation.runInSubprocess() def test_nodes_have_inline_values(self): tree = ast.parse("x = f(y, z=1)") for node in ast.walk(tree):