@@ -102,19 +102,22 @@ def test_include_easyblocks(self):
102102 myfoo_pyc_path = easybuild .easyblocks .myfoo .__file__
103103 myfoo_real_py_path = os .path .realpath (os .path .join (os .path .dirname (myfoo_pyc_path ), 'myfoo.py' ))
104104 self .assertTrue (os .path .samefile (up (myfoo_real_py_path , 1 ), myeasyblocks ))
105+ del sys .modules ['easybuild.easyblocks.myfoo' ]
105106
106107 import easybuild .easyblocks .generic .mybar
107108 mybar_pyc_path = easybuild .easyblocks .generic .mybar .__file__
108109 mybar_real_py_path = os .path .realpath (os .path .join (os .path .dirname (mybar_pyc_path ), 'mybar.py' ))
109110 self .assertTrue (os .path .samefile (up (mybar_real_py_path , 2 ), myeasyblocks ))
111+ del sys .modules ['easybuild.easyblocks.generic.mybar' ]
110112
111113 # existing (test) easyblocks are unaffected
112114 import easybuild .easyblocks .foofoo
113115 foofoo_path = os .path .dirname (os .path .dirname (easybuild .easyblocks .foofoo .__file__ ))
114116 self .assertTrue (os .path .samefile (foofoo_path , test_easyblocks ))
117+ del sys .modules ['easybuild.easyblocks.foofoo' ]
115118
116119 def test_include_easyblocks_priority (self ):
117- """Test whether easyblocks included via include_easyblocks() get prioroity over others."""
120+ """Test whether easyblocks included via include_easyblocks() get priority over others."""
118121 test_easyblocks = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'sandbox' , 'easybuild' , 'easyblocks' )
119122
120123 # make sure that test 'foo' easyblock is there
@@ -138,15 +141,23 @@ def test_include_easyblocks_priority(self):
138141 " pass" ,
139142 ])
140143 write_file (os .path .join (myeasyblocks , 'foo.py' ), foo_easyblock_txt )
144+
145+ # check that the sandboxed easyblock is imported before include_easyblocks is run
146+ foo_pyc_path = easybuild .easyblocks .foo .__file__
147+ foo_real_py_path = os .path .realpath (os .path .join (os .path .dirname (foo_pyc_path ), 'foo.py' ))
148+ self .assertTrue (os .path .samefile (os .path .dirname (os .path .dirname (foo_pyc_path )), test_easyblocks ))
149+ self .assertFalse (os .path .samefile (foo_real_py_path , os .path .join (myeasyblocks , 'foo.py' )))
150+
141151 include_easyblocks (self .test_prefix , [os .path .join (myeasyblocks , 'foo.py' )])
142152
153+ # check that the included easyblock is imported after include_easyblocks is run
143154 foo_pyc_path = easybuild .easyblocks .foo .__file__
144155 foo_real_py_path = os .path .realpath (os .path .join (os .path .dirname (foo_pyc_path ), 'foo.py' ))
145- self .assertFalse (os .path .samefile (os .path .dirname (foo_pyc_path ), test_easyblocks ))
156+ self .assertFalse (os .path .samefile (os .path .dirname (os . path . dirname ( foo_pyc_path ) ), test_easyblocks ))
146157 self .assertTrue (os .path .samefile (foo_real_py_path , os .path .join (myeasyblocks , 'foo.py' )))
147158
148- # 'undo' import of foo easyblock
149- del sys . modules [ 'easybuild.easyblocks.foo' ]
159+ # check that the included easyblock is not loaded
160+ self . assertFalse ( 'easybuild.easyblocks.foo' in sys . modules )
150161
151162 def test_include_mns (self ):
152163 """Test include_module_naming_schemes()."""
0 commit comments