@@ -85,8 +85,15 @@ void cleanupTempDir() throws Exception {
8585 @ Test
8686 void resolvePythonExecutable_venvLayout () throws Exception {
8787 tempDir = Files .createTempDirectory ("test-venv-" );
88- Path scriptsDir = Files .createDirectories (tempDir .resolve ("Scripts" ));
89- Path pythonExe = scriptsDir .resolve ("python.exe" );
88+ boolean isWindows = System .getProperty ("os.name" , "" ).toLowerCase ().contains ("win" );
89+ Path pythonExe ;
90+ if (isWindows ) {
91+ Path scriptsDir = Files .createDirectories (tempDir .resolve ("Scripts" ));
92+ pythonExe = scriptsDir .resolve ("python.exe" );
93+ } else {
94+ Path binDir = Files .createDirectories (tempDir .resolve ("bin" ));
95+ pythonExe = binDir .resolve ("python3" );
96+ }
9097 Files .createFile (pythonExe );
9198
9299 String resolved = PythonProcessManager .resolvePythonExecutable (tempDir );
@@ -96,7 +103,14 @@ void resolvePythonExecutable_venvLayout() throws Exception {
96103 @ Test
97104 void resolvePythonExecutable_standaloneLayout () throws Exception {
98105 tempDir = Files .createTempDirectory ("test-standalone-" );
99- Path pythonExe = tempDir .resolve ("python.exe" );
106+ boolean isWindows = System .getProperty ("os.name" , "" ).toLowerCase ().contains ("win" );
107+ Path pythonExe ;
108+ if (isWindows ) {
109+ pythonExe = tempDir .resolve ("python.exe" );
110+ } else {
111+ Path binDir = Files .createDirectories (tempDir .resolve ("bin" ));
112+ pythonExe = binDir .resolve ("python3" );
113+ }
100114 Files .createFile (pythonExe );
101115
102116 String resolved = PythonProcessManager .resolvePythonExecutable (tempDir );
@@ -106,24 +120,41 @@ void resolvePythonExecutable_standaloneLayout() throws Exception {
106120 @ Test
107121 void resolvePythonExecutable_venvLayoutPreferredOverStandalone () throws Exception {
108122 tempDir = Files .createTempDirectory ("test-both-" );
109- Path scriptsDir = Files .createDirectories (tempDir .resolve ("Scripts" ));
110- Path venvPy = scriptsDir .resolve ("python.exe" );
111- Files .createFile (venvPy );
112- Path standalonePy = tempDir .resolve ("python.exe" );
113- Files .createFile (standalonePy );
123+ boolean isWindows = System .getProperty ("os.name" , "" ).toLowerCase ().contains ("win" );
124+ Path preferredPy ;
125+ if (isWindows ) {
126+ Path scriptsDir = Files .createDirectories (tempDir .resolve ("Scripts" ));
127+ preferredPy = scriptsDir .resolve ("python.exe" );
128+ Files .createFile (preferredPy );
129+ Path standalonePy = tempDir .resolve ("python.exe" );
130+ Files .createFile (standalonePy );
131+ } else {
132+ Path binDir = Files .createDirectories (tempDir .resolve ("bin" ));
133+ preferredPy = binDir .resolve ("python3" );
134+ Files .createFile (preferredPy );
135+ Path fallbackPy = binDir .resolve ("python" );
136+ Files .createFile (fallbackPy );
137+ }
114138
115139 String resolved = PythonProcessManager .resolvePythonExecutable (tempDir );
116- assertEquals (venvPy .toAbsolutePath ().toString (), resolved ,
117- "venv layout (Scripts/python.exe) should be preferred over standalone (root python.exe) " );
140+ assertEquals (preferredPy .toAbsolutePath ().toString (), resolved ,
141+ "venv layout should be preferred over standalone" );
118142 }
119143
120144 @ Test
121145 void resolvePythonExecutable_fallbackWhenNeitherExists () {
122146 tempDir = Path .of ("nonexistent-" + System .nanoTime ());
123147 String resolved = PythonProcessManager .resolvePythonExecutable (tempDir );
124- assertTrue (resolved .endsWith ("Scripts/py" + "thon.exe" )
125- || resolved .endsWith ("Scripts\\ py" + "thon.exe" ),
126- "should fall back to Scripts/python.exe path: " + resolved );
148+ boolean isWindows = System .getProperty ("os.name" , "" ).toLowerCase ().contains ("win" );
149+ if (isWindows ) {
150+ assertTrue (resolved .endsWith ("Scripts/py" + "thon.exe" )
151+ || resolved .endsWith ("Scripts\\ py" + "thon.exe" ),
152+ "should fall back to Scripts/python.exe path: " + resolved );
153+ } else {
154+ assertTrue (resolved .endsWith ("bin/python3" )
155+ || resolved .endsWith ("bin\\ python3" ),
156+ "should fall back to bin/python3 path: " + resolved );
157+ }
127158 }
128159
129160 @ Test
0 commit comments