@@ -497,12 +497,12 @@ def test_curr_module_paths(self):
497497 self .assertEqual (curr_module_paths (), [])
498498 self .assertEqual (curr_module_paths (clean = False ), ['' ])
499499
500- os .environ ['MODULEPATH' ] = '%s:%s:%s' % ( test1 , test2 , test3 )
500+ os .environ ['MODULEPATH' ] = os . pathsep . join ([ test1 , test2 , test3 ] )
501501 self .assertEqual (curr_module_paths (), [test1 , test2 , test3 ])
502502 self .assertEqual (curr_module_paths (clean = False ), [test1 , test2 , test3 ])
503503
504504 # empty entries and non-existing directories are filtered out
505- os .environ ['MODULEPATH' ] = '/doesnotexist:%s::%s:' % ( test2 , test1 )
505+ os .environ ['MODULEPATH' ] = os . pathsep . join ([ '/doesnotexist' , test2 , '' , test1 , '' ] )
506506 self .assertEqual (curr_module_paths (), [test2 , test1 ])
507507 # Disabling the clean returns them
508508 self .assertEqual (curr_module_paths (clean = False ), ['/doesnotexist' , test2 , '' , test1 , '' ])
@@ -542,7 +542,7 @@ def test_check_module_path(self):
542542 self .assertEqual (os .environ ['MODULEPATH' ], os .pathsep .join ([mod_install_dir , test1 , test2 ]))
543543
544544 # check behaviour if non-existing directories are included in $MODULEPATH
545- os .environ ['MODULEPATH' ] = '%s: /does/not/exist:%s' % ( test3 , test2 )
545+ os .environ ['MODULEPATH' ] = os . pathsep . join ([ test3 , ' /does/not/exist' , test2 ] )
546546 modtool .check_module_path ()
547547 # non-existing dir is filtered from mod_paths, but stays in $MODULEPATH
548548 self .assertEqual (modtool .mod_paths , [mod_install_dir , test1 , test3 , test2 ])
@@ -567,11 +567,11 @@ def test_check_module_path_hmns(self):
567567 doesnotexist = os .path .join (self .test_prefix , 'doesnotexist' )
568568 self .assertFalse (os .path .exists (doesnotexist ))
569569
570- os .environ ['MODULEPATH' ] = '%s:%s' % ( core_mod_dir , doesnotexist )
570+ os .environ ['MODULEPATH' ] = os . pathsep . join ([ core_mod_dir , doesnotexist ] )
571571 modtool = modules_tool ()
572572
573573 self .assertEqual (modtool .mod_paths , [os .path .dirname (core_mod_dir ), core_mod_dir ])
574- self .assertEqual (os .environ ['MODULEPATH' ], '%s:%s:%s' % ( top_mod_dir , core_mod_dir , doesnotexist ))
574+ self .assertEqual (os .environ ['MODULEPATH' ], os . pathsep . join ([ top_mod_dir , core_mod_dir , doesnotexist ] ))
575575
576576 # hack prepend_module_path to make sure it's not called again if check_module_path is called again;
577577 # prepend_module_path is fairly expensive, so should be avoided,
@@ -585,7 +585,7 @@ def broken_prepend_module_path(*args, **kwargs):
585585 modtool .check_module_path ()
586586
587587 self .assertEqual (modtool .mod_paths , [os .path .dirname (core_mod_dir ), core_mod_dir ])
588- self .assertEqual (os .environ ['MODULEPATH' ], '%s:%s:%s' % ( top_mod_dir , core_mod_dir , doesnotexist ))
588+ self .assertEqual (os .environ ['MODULEPATH' ], os . pathsep . join ([ top_mod_dir , core_mod_dir , doesnotexist ] ))
589589
590590 def test_prepend_module_path (self ):
591591 """Test prepend_module_path method."""
@@ -728,7 +728,11 @@ def test_wrong_modulepath(self):
728728 """Test whether modules tool can deal with a broken $MODULEPATH."""
729729 test_modules_path = os .path .realpath (os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'modules' ))
730730 modules_test_installpath = os .path .join (self .test_installpath , 'modules' , 'all' )
731- os .environ ['MODULEPATH' ] = '/some/non-existing/path:/this/doesnt/exists/anywhere:%s' % test_modules_path
731+ os .environ ['MODULEPATH' ] = os .pathsep .join ([
732+ '/some/non-existing/path' ,
733+ '/this/doesnt/exists/anywhere' ,
734+ test_modules_path
735+ ])
732736 init_config ()
733737 # purposely *not* using self.modtool here;
734738 # need to check whether creating new ModulesTool instance doesn't break when $MODULEPATH contains faulty paths
@@ -1092,10 +1096,11 @@ def test_modules_tool_stateless(self):
10921096
10931097 def test_mk_module_cache_key (self ):
10941098 """Test mk_module_cache_key method."""
1095- os .environ ['MODULEPATH' ] = '%s:/tmp/test' % self .test_prefix
1099+ module_path = os .pathsep .join ([self .test_prefix , '/tmp/test' ])
1100+ os .environ ['MODULEPATH' ] = module_path
10961101 res = self .modtool .mk_module_cache_key ('thisisapartialkey' )
10971102 self .assertTrue (isinstance (res , tuple ))
1098- self .assertEqual (res , ('MODULEPATH=%s:/tmp/test ' % self . test_prefix , self .modtool .COMMAND , 'thisisapartialkey' ))
1103+ self .assertEqual (res , ('MODULEPATH=%s' % module_path , self .modtool .COMMAND , 'thisisapartialkey' ))
10991104
11001105 del os .environ ['MODULEPATH' ]
11011106 res = self .modtool .mk_module_cache_key ('thisisapartialkey' )
@@ -1174,11 +1179,11 @@ def test_module_use_unuse(self):
11741179
11751180 self .assertFalse (test_dir1 in os .environ .get ('MODULEPATH' , '' ))
11761181 self .modtool .use (test_dir1 )
1177- self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:' % test_dir1 ))
1182+ self .assertTrue (os .environ ['MODULEPATH' ].startswith (test_dir1 + os . pathsep ))
11781183 self .modtool .use (test_dir2 )
1179- self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:' % test_dir2 ))
1184+ self .assertTrue (os .environ ['MODULEPATH' ].startswith (test_dir2 + os . pathsep ))
11801185 self .modtool .use (test_dir3 )
1181- self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:' % test_dir3 ))
1186+ self .assertTrue (os .environ ['MODULEPATH' ].startswith (test_dir3 + os . pathsep ))
11821187
11831188 # Adding an empty modulepath is not possible
11841189 modulepath = os .environ .get ('MODULEPATH' , '' )
@@ -1209,7 +1214,7 @@ def test_module_use_unuse(self):
12091214
12101215 # also test use with high priority
12111216 self .modtool .use (test_dir2 , priority = 10000 )
1212- self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:' % test_dir2 ))
1217+ self .assertTrue (os .environ ['MODULEPATH' ].startswith (test_dir2 + os . pathsep ))
12131218
12141219 self .modtool .load (['test' ])
12151220 self .assertEqual (os .getenv ('TEST123' ), 'two' )
@@ -1221,8 +1226,9 @@ def test_module_use_unuse(self):
12211226 old_module_path = os .environ ['MODULEPATH' ]
12221227 self .modtool ._set_module_path (['/foo' ])
12231228 self .assertEqual (os .environ ['MODULEPATH' ], '/foo' )
1224- self .modtool ._set_module_path (['/foo' , '/bar' ])
1225- self .assertEqual (os .environ ['MODULEPATH' ], '/foo:/bar' )
1229+ foo_and_bar_paths = ['/foo' , '/bar' ]
1230+ self .modtool ._set_module_path (foo_and_bar_paths )
1231+ self .assertEqual (os .environ ['MODULEPATH' ], os .pathsep .join (foo_and_bar_paths ))
12261232 self .modtool ._set_module_path (['' ])
12271233 self .assertEqual (os .environ ['MODULEPATH' ], '' )
12281234 self .modtool ._set_module_path ([])
@@ -1232,8 +1238,8 @@ def test_module_use_unuse(self):
12321238 # Same for generators
12331239 self .modtool ._set_module_path (i for i in ['/foo' ])
12341240 self .assertEqual (os .environ ['MODULEPATH' ], '/foo' )
1235- self .modtool ._set_module_path (i for i in [ '/foo' , '/bar' ] )
1236- self .assertEqual (os .environ ['MODULEPATH' ], '/foo:/bar' )
1241+ self .modtool ._set_module_path (i for i in foo_and_bar_paths )
1242+ self .assertEqual (os .environ ['MODULEPATH' ], os . pathsep . join ( foo_and_bar_paths ) )
12371243 self .modtool ._set_module_path (i for i in ['' ])
12381244 self .assertEqual (os .environ ['MODULEPATH' ], '' )
12391245 self .modtool ._set_module_path (i for i in [])
@@ -1243,7 +1249,9 @@ def test_module_use_unuse(self):
12431249 # check whether prepend with priority actually works (priority is specific to Lmod)
12441250 self .modtool .use (test_dir1 , priority = 100 )
12451251 self .modtool .use (test_dir3 )
1246- self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:%s:%s:' % (test_dir2 , test_dir1 , test_dir3 )))
1252+ self .assertTrue (os .environ ['MODULEPATH' ].startswith (
1253+ os .pathsep .join ([test_dir2 , test_dir1 , test_dir3 ])
1254+ ))
12471255 self .modtool .load (['test' ])
12481256 self .assertEqual (os .getenv ('TEST123' ), 'two' )
12491257 self .modtool .unload (['test' ])
@@ -1563,7 +1571,7 @@ def test_modulecmd_strip_source(self):
15631571 write_file (modulecmd , modulecmd_txt )
15641572 adjust_permissions (modulecmd , stat .S_IXUSR , add = True )
15651573
1566- os .environ ['PATH' ] = '%s:%s' % ( self .test_prefix , os .getenv ('PATH' ))
1574+ os .environ ['PATH' ] = os . pathsep . join ([ self .test_prefix , os .getenv ('PATH' )] )
15671575
15681576 modtool = EnvironmentModulesC ()
15691577 modtool .run_module ('load' , 'test123' )
0 commit comments