4949
5050if HAVE_ENTRY_POINTS :
5151 from importlib .metadata import DistributionFinder , Distribution
52+ else :
53+ DistributionFinder = object
54+ Distribution = object
5255
5356
5457MOCK_HOOK_EP_NAME = "mock_hook"
@@ -163,6 +166,8 @@ def setUp(self):
163166 # Create a mock entry point for testing
164167 mock_hook_file = os .path .join (self .tmpdir , f'{ filename_root } .py' )
165168 write_file (mock_hook_file , MOCK_EP_FILE )
169+ else :
170+ self .skipTest ("Entry points not available in this Python version" )
166171
167172 def tearDown (self ):
168173 """Clean up the test environment."""
@@ -178,24 +183,14 @@ def tearDown(self):
178183 for idx in reversed (torm ):
179184 del sys .meta_path [idx ]
180185
181- def test_entrypoints_get_group_too_old_python (self ):
182- """Test retrieving entrypoints for a specific group with too old Python version."""
183- if HAVE_ENTRY_POINTS :
184- self .skipTest ("Entry points available in this Python version" )
185- self .assertRaises (EasyBuildError , get_group_entrypoints , HOOKS_ENTRYPOINT )
186-
187186 def test_entrypoints_get_group (self ):
188187 """Test retrieving entrypoints for a specific group."""
189- if not HAVE_ENTRY_POINTS :
190- self .skipTest ("Entry points not available in this Python version" )
191-
192188 expected = {
193189 HOOKS_ENTRYPOINT : MOCK_HOOK_EP_NAME ,
194190 EASYBLOCK_ENTRYPOINT : MOCK_EASYBLOCK_EP_NAME ,
195191 TOOLCHAIN_ENTRYPOINT : MOCK_TOOLCHAIN_EP_NAME ,
196192 }
197193
198- # init_config()
199194 for group in [HOOKS_ENTRYPOINT , EASYBLOCK_ENTRYPOINT , TOOLCHAIN_ENTRYPOINT ]:
200195 epts = get_group_entrypoints (group )
201196 self .assertIsInstance (epts , set , f"Expected set for group { group } " )
@@ -214,11 +209,6 @@ def test_entrypoints_list_easyblocks(self):
214209 """
215210 Tests for list_easyblocks function with entry points enabled.
216211 """
217- if not HAVE_ENTRY_POINTS :
218- self .skipTest ("Entry points not available in this Python version" )
219-
220- # init_config()
221- # print('-------', build_option('use_entrypoints', default='1234'))
222212 txt = list_easyblocks ()
223213 self .assertNotIn ("TestEasyBlock" , txt , "TestEasyBlock should not be listed without entry points enabled" )
224214
@@ -230,10 +220,6 @@ def test_entrypoints_list_toolchains(self):
230220 """
231221 Tests for list_toolchains function with entry points enabled.
232222 """
233- if not HAVE_ENTRY_POINTS :
234- self .skipTest ("Entry points not available in this Python version" )
235-
236- # init_config()
237223 txt = list_toolchains ()
238224 self .assertNotIn (MOCK_TOOLCHAIN , txt , f"{ MOCK_TOOLCHAIN } should not be listed without entry points enabled" )
239225
@@ -246,9 +232,6 @@ def test_entrypoints_get_module_path(self):
246232 """
247233 Tests for get_module_path function with entry points enabled.
248234 """
249- if not HAVE_ENTRY_POINTS :
250- self .skipTest ("Entry points not available in this Python version" )
251-
252235 module_path = get_module_path (MOCK_EASYBLOCK )
253236 self .assertIn ('.generic.' , module_path , "Module path should contain '.generic.'" )
254237
0 commit comments