From 0e36c070809dc5c382bdd0d1c60aa52b7f97ca9a Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 17 Jun 2026 20:25:41 +0200 Subject: [PATCH] cleanup [python]: Load `randomBinary` in lazy manner. Exception in `PathEnvironmentVariableUtil` shouldn't lead to class initialization exception (cherry picked from commit 0d4748688f1e259ab3c00f770de63df5e3a66559) GitOrigin-RevId: e445dcf09106d955caea5f27cc59284947895a12 --- .../intellij/python/junit5Tests/TestTools.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/TestTools.kt b/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/TestTools.kt index 5f8fcbd0f6da..b6f0cc893736 100644 --- a/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/TestTools.kt +++ b/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/TestTools.kt @@ -18,14 +18,15 @@ import kotlin.io.path.Path /** * Binary that isn't python. To be used to test validation. */ -val randomBinary: PythonBinary = Path( - if (SystemInfoRt.isWindows) { - // ftp.exe is faster than cmd.exe and powershell.exe - PathEnvironmentVariableUtil.findInPath("ftp.exe")?.path ?: error("No ftp on Windows?") - } - else { - "/bin/sh" - }) +val randomBinary: PythonBinary + get() = Path( + if (SystemInfoRt.isWindows) { + // ftp.exe is faster than cmd.exe and powershell.exe + PathEnvironmentVariableUtil.findInPath("ftp.exe")?.path ?: error("No ftp on Windows?") + } + else { + "/bin/sh" + }) /** * Fails if [this] is not [Result.Failure]