@@ -60,9 +60,11 @@ def setUp(self):
6060 self .py_env_create = os .path .join (path_to_ctsm_root (), "py_env_create" )
6161 assert os .path .exists (self .py_env_create )
6262
63- # Get path to testing condafile
63+ # Get path to testing conda/mambafile:
64+ # conda needs a completely empty file (# comments okay) as of 25.5.1, but mamba as of 2.3.1
65+ # needs at least some YML structure.
6466 self .empty_condafile = os .path .join (path_to_ctsm_root (), "python" , "empty.txt" )
65- assert os .path .exists ( self . empty_condafile )
67+ self . empty_mambafile = os .path .join ( path_to_ctsm_root (), "python" , "empty.yml" )
6668
6769 # Set up other variables
6870 self .env_names = []
@@ -89,7 +91,12 @@ def _create_empty_env(self, check=None, extra_args=None, expect_error=False, new
8991 self .env_names .append (get_unique_env_name (5 ))
9092
9193 # Form and run command
92- cmd = [self .py_env_create , "-n" , self .env_names [- 1 ], "-f" , self .empty_condafile , "--yes" ]
94+ if extra_args is not None and ("-m" in extra_args or "--mamba" in extra_args ):
95+ empty_file = self .empty_mambafile
96+ else :
97+ empty_file = self .empty_condafile
98+ assert os .path .exists (empty_file )
99+ cmd = [self .py_env_create , "-n" , self .env_names [- 1 ], "-f" , empty_file , "--yes" ]
93100 if extra_args :
94101 cmd += extra_args
95102 out = subprocess .run (cmd , capture_output = True , text = True , check = False )
@@ -327,7 +334,8 @@ def test_complete_py_env_create(self):
327334 raise e
328335 env_list = get_conda_envs ()
329336 for env_name in self .env_names :
330- assert does_env_exist (env_name , env_list )
337+ if not does_env_exist (env_name , env_list ):
338+ raise AssertionError (f"environment not found: { env_name } " )
331339
332340 def test_complete_py_env_create_mamba (self ):
333341 """
@@ -358,7 +366,8 @@ def test_complete_py_env_create_mamba(self):
358366 raise e
359367 env_list = get_conda_envs ()
360368 for env_name in self .env_names :
361- assert does_env_exist (env_name , env_list )
369+ if not does_env_exist (env_name , env_list ):
370+ raise AssertionError (f"environment not found: { env_name } " )
362371
363372
364373if __name__ == "__main__" :
0 commit comments