@@ -500,12 +500,12 @@ def test_curr_module_paths(self):
500500        self .assertEqual (curr_module_paths (), [])
501501        self .assertEqual (curr_module_paths (clean = False ), ['' ])
502502
503-         os .environ ['MODULEPATH' ] =  '%s:%s:%s'   %  ( test1 , test2 , test3 )
503+         os .environ ['MODULEPATH' ] =  os . pathsep . join ([ test1 , test2 , test3 ] )
504504        self .assertEqual (curr_module_paths (), [test1 , test2 , test3 ])
505505        self .assertEqual (curr_module_paths (clean = False ), [test1 , test2 , test3 ])
506506
507507        # empty entries and non-existing directories are filtered out 
508-         os .environ ['MODULEPATH' ] =  '/doesnotexist:%s::%s:'    %  ( test2 , test1 )
508+         os .environ ['MODULEPATH' ] =  os . pathsep . join ([ '/doesnotexist'  ,  test2 , '' ,  test1 ,  '' ] )
509509        self .assertEqual (curr_module_paths (), [test2 , test1 ])
510510        # Disabling the clean returns them 
511511        self .assertEqual (curr_module_paths (clean = False ), ['/doesnotexist' , test2 , '' , test1 , '' ])
@@ -545,7 +545,7 @@ def test_check_module_path(self):
545545        self .assertEqual (os .environ ['MODULEPATH' ], os .pathsep .join ([mod_install_dir , test1 , test2 ]))
546546
547547        # check behaviour if non-existing directories are included in $MODULEPATH 
548-         os .environ ['MODULEPATH' ] =  '%s: /does/not/exist:%s'   %  ( test3 , test2 )
548+         os .environ ['MODULEPATH' ] =  os . pathsep . join ([ test3 ,  ' /does/not/exist' test2 ] )
549549        modtool .check_module_path ()
550550        # non-existing dir is filtered from mod_paths, but stays in $MODULEPATH 
551551        self .assertEqual (modtool .mod_paths , [mod_install_dir , test1 , test3 , test2 ])
@@ -570,11 +570,11 @@ def test_check_module_path_hmns(self):
570570        doesnotexist  =  os .path .join (self .test_prefix , 'doesnotexist' )
571571        self .assertNotExists (doesnotexist )
572572
573-         os .environ ['MODULEPATH' ] =  '%s:%s'   %  ( core_mod_dir , doesnotexist )
573+         os .environ ['MODULEPATH' ] =  os . pathsep . join ([ core_mod_dir , doesnotexist ] )
574574        modtool  =  modules_tool ()
575575
576576        self .assertEqual (modtool .mod_paths , [os .path .dirname (core_mod_dir ), core_mod_dir ])
577-         self .assertEqual (os .environ ['MODULEPATH' ], '%s:%s:%s'   %  ( top_mod_dir , core_mod_dir , doesnotexist ))
577+         self .assertEqual (os .environ ['MODULEPATH' ], os . pathsep . join ([ top_mod_dir , core_mod_dir , doesnotexist ] ))
578578
579579        # hack prepend_module_path to make sure it's not called again if check_module_path is called again; 
580580        # prepend_module_path is fairly expensive, so should be avoided, 
@@ -588,7 +588,7 @@ def broken_prepend_module_path(*args, **kwargs):
588588        modtool .check_module_path ()
589589
590590        self .assertEqual (modtool .mod_paths , [os .path .dirname (core_mod_dir ), core_mod_dir ])
591-         self .assertEqual (os .environ ['MODULEPATH' ], '%s:%s:%s'   %  ( top_mod_dir , core_mod_dir , doesnotexist ))
591+         self .assertEqual (os .environ ['MODULEPATH' ], os . pathsep . join ([ top_mod_dir , core_mod_dir , doesnotexist ] ))
592592
593593    def  test_prepend_module_path (self ):
594594        """Test prepend_module_path method.""" 
@@ -744,7 +744,11 @@ def test_wrong_modulepath(self):
744744        """Test whether modules tool can deal with a broken $MODULEPATH.""" 
745745        test_modules_path  =  os .path .realpath (os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'modules' ))
746746        modules_test_installpath  =  os .path .join (self .test_installpath , 'modules' , 'all' )
747-         os .environ ['MODULEPATH' ] =  '/some/non-existing/path:/this/doesnt/exists/anywhere:%s'  %  test_modules_path 
747+         os .environ ['MODULEPATH' ] =  os .pathsep .join ([
748+             '/some/non-existing/path' ,
749+             '/this/doesnt/exists/anywhere' ,
750+             test_modules_path 
751+         ])
748752        init_config ()
749753        # purposely *not* using self.modtool here; 
750754        # need to check whether creating new ModulesTool instance doesn't break when $MODULEPATH contains faulty paths 
@@ -1107,10 +1111,11 @@ def test_modules_tool_stateless(self):
11071111
11081112    def  test_mk_module_cache_key (self ):
11091113        """Test mk_module_cache_key method.""" 
1110-         os .environ ['MODULEPATH' ] =  '%s:/tmp/test'  %  self .test_prefix 
1114+         module_path  =  os .pathsep .join ([self .test_prefix , '/tmp/test' ])
1115+         os .environ ['MODULEPATH' ] =  module_path 
11111116        res  =  self .modtool .mk_module_cache_key ('thisisapartialkey' )
11121117        self .assertIsInstance (res , tuple )
1113-         self .assertEqual (res , ('MODULEPATH=%s:/tmp/test '  %  self . test_prefix , self .modtool .COMMAND , 'thisisapartialkey' ))
1118+         self .assertEqual (res , ('MODULEPATH=%s'  %  module_path , self .modtool .COMMAND , 'thisisapartialkey' ))
11141119
11151120        del  os .environ ['MODULEPATH' ]
11161121        res  =  self .modtool .mk_module_cache_key ('thisisapartialkey' )
@@ -1189,11 +1194,11 @@ def test_module_use_unuse(self):
11891194
11901195        self .assertNotIn (test_dir1 , os .environ .get ('MODULEPATH' , '' ))
11911196        self .modtool .use (test_dir1 )
1192-         self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:'   %   test_dir1 ))
1197+         self .assertTrue (os .environ ['MODULEPATH' ].startswith (test_dir1   +   os . pathsep ))
11931198        self .modtool .use (test_dir2 )
1194-         self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:'   %   test_dir2 ))
1199+         self .assertTrue (os .environ ['MODULEPATH' ].startswith (test_dir2   +   os . pathsep ))
11951200        self .modtool .use (test_dir3 )
1196-         self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:'   %   test_dir3 ))
1201+         self .assertTrue (os .environ ['MODULEPATH' ].startswith (test_dir3   +   os . pathsep ))
11971202
11981203        # Adding an empty modulepath is not possible 
11991204        modulepath  =  os .environ .get ('MODULEPATH' , '' )
@@ -1224,7 +1229,7 @@ def test_module_use_unuse(self):
12241229
12251230        # also test use with high priority 
12261231        self .modtool .use (test_dir2 , priority = 10000 )
1227-         self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:'   %   test_dir2 ))
1232+         self .assertTrue (os .environ ['MODULEPATH' ].startswith (test_dir2   +   os . pathsep ))
12281233
12291234        self .modtool .load (['test' ])
12301235        self .assertEqual (os .getenv ('TEST123' ), 'two' )
@@ -1236,8 +1241,9 @@ def test_module_use_unuse(self):
12361241            old_module_path  =  os .environ ['MODULEPATH' ]
12371242            self .modtool ._set_module_path (['/foo' ])
12381243            self .assertEqual (os .environ ['MODULEPATH' ], '/foo' )
1239-             self .modtool ._set_module_path (['/foo' , '/bar' ])
1240-             self .assertEqual (os .environ ['MODULEPATH' ], '/foo:/bar' )
1244+             foo_and_bar_paths  =  ['/foo' , '/bar' ]
1245+             self .modtool ._set_module_path (foo_and_bar_paths )
1246+             self .assertEqual (os .environ ['MODULEPATH' ], os .pathsep .join (foo_and_bar_paths ))
12411247            self .modtool ._set_module_path (['' ])
12421248            self .assertEqual (os .environ ['MODULEPATH' ], '' )
12431249            self .modtool ._set_module_path ([])
@@ -1247,8 +1253,8 @@ def test_module_use_unuse(self):
12471253            # Same for generators 
12481254            self .modtool ._set_module_path (i  for  i  in  ['/foo' ])
12491255            self .assertEqual (os .environ ['MODULEPATH' ], '/foo' )
1250-             self .modtool ._set_module_path (i  for  i  in  [ '/foo' ,  '/bar' ] )
1251-             self .assertEqual (os .environ ['MODULEPATH' ], '/foo:/bar' )
1256+             self .modtool ._set_module_path (i  for  i  in  foo_and_bar_paths )
1257+             self .assertEqual (os .environ ['MODULEPATH' ], os . pathsep . join ( foo_and_bar_paths ) )
12521258            self .modtool ._set_module_path (i  for  i  in  ['' ])
12531259            self .assertEqual (os .environ ['MODULEPATH' ], '' )
12541260            self .modtool ._set_module_path (i  for  i  in  [])
@@ -1258,7 +1264,9 @@ def test_module_use_unuse(self):
12581264            # check whether prepend with priority actually works (priority is specific to Lmod) 
12591265            self .modtool .use (test_dir1 , priority = 100 )
12601266            self .modtool .use (test_dir3 )
1261-             self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:%s:%s:'  %  (test_dir2 , test_dir1 , test_dir3 )))
1267+             self .assertTrue (os .environ ['MODULEPATH' ].startswith (
1268+                 os .pathsep .join ([test_dir2 , test_dir1 , test_dir3 ])
1269+             ))
12621270            self .modtool .load (['test' ])
12631271            self .assertEqual (os .getenv ('TEST123' ), 'two' )
12641272            self .modtool .unload (['test' ])
@@ -1587,7 +1595,7 @@ def test_modulecmd_strip_source(self):
15871595        write_file (modulecmd , modulecmd_txt )
15881596        adjust_permissions (modulecmd , stat .S_IXUSR , add = True )
15891597
1590-         os .environ ['PATH' ] =  '%s:%s'   %  ( self .test_prefix , os .getenv ('PATH' ))
1598+         os .environ ['PATH' ] =  os . pathsep . join ([ self .test_prefix , os .getenv ('PATH' )] )
15911599
15921600        modtool  =  EnvironmentModulesC ()
15931601        modtool .run_module ('load' , 'test123' )
0 commit comments