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
This commit is contained in:
Andrey Vokin
2026-09-05 09:43:44 +00:00
committed by intellij-monorepo-bot
parent 0cbcaf3e49
commit 0a36c2119a
@@ -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"])