@@ -167,42 +167,14 @@ def test_environment_error_on_bogus_khiops_env_script(self):
167167 output_msg = str (context .exception )
168168 self .assertEqual (output_msg , expected_msg )
169169
170- def test_runner_with_conda_based_environment (self ):
171- """Test that local runner works in non-Conda, Conda-based environments"""
172-
173- # Emulate Conda-based environment:
174- # - remove $CONDA_PREFIX/bin from $PATH
175- # - unset `CONDA_PREFIX`
176- # - create new KhiopsLocalRunner and initialize its Khiops binary
177- # directory
178- # - check that the Khiops binary directory contains the MODL* binaries
179- # and `mpiexec` (which should be its default location)
180- conda_prefix = None
181- if "CONDA_PREFIX" in os .environ :
182- # Remove `CONDA_PREFIX/bin` from `PATH`
183- conda_prefix_bin = os .path .join (os .environ ["CONDA_PREFIX" ], "bin" )
184- os .environ ["PATH" ] = os .pathsep .join (
185- path_fragment
186- for path_fragment in os .environ ["PATH" ].split (os .pathsep )
187- if path_fragment != conda_prefix_bin
188- )
189-
190- # Store existing CONDA_PREFIX
191- conda_prefix = os .environ ["CONDA_PREFIX" ]
192-
193- # Unset `CONDA_PREFIX`
194- del os .environ ["CONDA_PREFIX" ]
195-
196- # Create a fresh local runner
197- runner = KhiopsLocalRunner ()
198-
199- # Restore CONDA_PREFIX
200- if conda_prefix is not None :
201- os .environ ["CONDA_PREFIX" ] = conda_prefix
170+ def test_runner_environment_initialization (self ):
171+ """Test that local runner initializes/ed its environment properly
202172
203- # Restore `CONDA_PREFIX/bin` into `PATH`
204- conda_prefix_bin = os .path .join (conda_prefix , "bin" )
205- os .environ ["PATH" ] = os .pathsep .join ([conda_prefix_bin , os .environ ["PATH" ]])
173+ .. note::
174+ To test a real initialization this test should be executed alone.
175+ """
176+ # Obtain the current runner
177+ runner = kh .get_runner ()
206178
207179 # Check that MODL* files as set in the runner exist and are executable
208180 self .assertTrue (os .path .isfile (runner .khiops_path ))
@@ -211,12 +183,11 @@ def test_runner_with_conda_based_environment(self):
211183 self .assertTrue (os .access (runner .khiops_coclustering_path , os .X_OK ))
212184
213185 # Check that mpiexec is set correctly in the runner:
214- mpi_command_args = runner .mpi_command_args
215- self .assertTrue (len (mpi_command_args ) > 0 )
216- mpiexec_path = runner .mpi_command_args [0 ]
217- self .assertTrue (os .path .exists (mpiexec_path ))
218- self .assertTrue (os .path .isfile (mpiexec_path ))
219- self .assertTrue (os .access (mpiexec_path , os .X_OK ))
186+ if runner .mpi_command_args :
187+ mpiexec_path = runner .mpi_command_args [0 ]
188+ self .assertTrue (os .path .exists (mpiexec_path ))
189+ self .assertTrue (os .path .isfile (mpiexec_path ))
190+ self .assertTrue (os .access (mpiexec_path , os .X_OK ))
220191
221192
222193class KhiopsMultitableFitTests (unittest .TestCase ):
0 commit comments