@@ -1163,18 +1163,6 @@ def test_module_use_unuse(self):
11631163 self .modtool .use (test_dir3 )
11641164 self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:' % test_dir3 ))
11651165
1166- # Using an empty path still works (technically)
1167- old_module_path = os .environ ['MODULEPATH' ]
1168- self .modtool .use ('' )
1169- self .assertEqual (os .environ ['MODULEPATH' ], ':' + old_module_path )
1170- self .modtool .unuse ('' )
1171- self .assertEqual (os .environ ['MODULEPATH' ], old_module_path )
1172- # Even works when the whole path is empty
1173- os .environ ['MODULEPATH' ] = ''
1174- self .modtool .unuse ('' )
1175- self .assertFalse ('MODULEPATH' in os .environ )
1176- os .environ ['MODULEPATH' ] = old_module_path # Restore
1177-
11781166 # make sure the right test module is loaded
11791167 self .modtool .load (['test' ])
11801168 self .assertEqual (os .getenv ('TEST123' ), 'three' )
@@ -1205,8 +1193,9 @@ def test_module_use_unuse(self):
12051193 self .assertEqual (os .getenv ('TEST123' ), 'two' )
12061194 self .modtool .unload (['test' ])
12071195
1208- # check whether prepend with priority actually works (only for Lmod)
1196+ # Tests for Lmod only
12091197 if isinstance (self .modtool , Lmod ):
1198+ # check whether prepend with priority actually works (priority is specific to Lmod)
12101199 self .modtool .use (test_dir1 , priority = 100 )
12111200 self .modtool .use (test_dir3 )
12121201 self .assertTrue (os .environ ['MODULEPATH' ].startswith ('%s:%s:%s:' % (test_dir2 , test_dir1 , test_dir3 )))
@@ -1224,8 +1213,8 @@ def test_module_use_unuse(self):
12241213 self .assertEqual (os .getenv ('TEST123' ), 'three' )
12251214 self .modtool .unload (['test' ])
12261215
1227- # Also test that load and unload a single path works when it is the only one
1228- # Only for LMod as we have some shortcuts for avoiding the module call there
1216+ # Check load and unload for a single path when it is the only one
1217+ # Only for Lmod as we have some shortcuts for avoiding the module call there
12291218 old_module_path = os .environ ['MODULEPATH' ]
12301219 del os .environ ['MODULEPATH' ]
12311220 self .modtool .use (test_dir1 )
@@ -1234,6 +1223,18 @@ def test_module_use_unuse(self):
12341223 self .assertFalse ('MODULEPATH' in os .environ )
12351224 os .environ ['MODULEPATH' ] = old_module_path # Restore
12361225
1226+ # Using an empty path still works (technically) (Lmod only, ignored by Tcl)
1227+ old_module_path = os .environ ['MODULEPATH' ]
1228+ self .modtool .use ('' )
1229+ self .assertEqual (os .environ ['MODULEPATH' ], ':' + old_module_path )
1230+ self .modtool .unuse ('' )
1231+ self .assertEqual (os .environ ['MODULEPATH' ], old_module_path )
1232+ # Even works when the whole path is empty
1233+ os .environ ['MODULEPATH' ] = ''
1234+ self .modtool .unuse ('' )
1235+ self .assertFalse ('MODULEPATH' in os .environ )
1236+ os .environ ['MODULEPATH' ] = old_module_path # Restore
1237+
12371238 def test_module_use_bash (self ):
12381239 """Test whether effect of 'module use' is preserved when a new bash session is started."""
12391240 # this test is here as check for a nasty bug in how the modules tool is deployed
0 commit comments