From 0a36c2119af0b0a7738d6b61a4e0e79a41be2a96 Mon Sep 17 00:00:00 2001 From: Andrey Vokin Date: Sat, 5 Sep 2026 09:40:23 +0200 Subject: [PATCH] PY-91903 Guard recursive while-loop inference test With better control-flow inference disabled, code-analysis and user-initiated contexts can infer different types for the loop. Run the test only when the inference mode it was written for is enabled. (cherry picked from commit d7eaaf17258702d94731882b668c354713a5e633) IJ-MR-221796 GitOrigin-RevId: b0a3c075288003a5a7b87913c255710c568c1f83 --- .../python/types/PyInferenceMiscTypeTest.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/python/testSrc/com/jetbrains/python/types/PyInferenceMiscTypeTest.kt b/python/testSrc/com/jetbrains/python/types/PyInferenceMiscTypeTest.kt index f708ab41b071..a9ddfb3a5a11 100644 --- a/python/testSrc/com/jetbrains/python/types/PyInferenceMiscTypeTest.kt +++ b/python/testSrc/com/jetbrains/python/types/PyInferenceMiscTypeTest.kt @@ -249,13 +249,17 @@ class PyInferenceMiscTypeTest : PyCodeInsightTestCase() { inner class RecursionAndFixedPointLoops { @Test @TestFor(issues = ["PY-76659"]) - fun `recursive resolve in while loop`() = test(""" - x = 42 - while x: - x = x + 1 - expr = x - #└ TYPE Literal[42] | int - """) + fun `recursive resolve in while loop`() { + if (!Registry.`is`("python.use.better.control.flow.type.inference")) return + + test(""" + x = 42 + while x: + x = x + 1 + expr = x + #└ TYPE Literal[42] | int + """) + } @Test @TestFor(issues = ["PY-76659"])