49
49
50
50
if HAVE_ENTRY_POINTS :
51
51
from importlib .metadata import DistributionFinder , Distribution
52
+ else :
53
+ DistributionFinder = object
54
+ Distribution = object
52
55
53
56
54
57
MOCK_HOOK_EP_NAME = "mock_hook"
@@ -163,6 +166,8 @@ def setUp(self):
163
166
# Create a mock entry point for testing
164
167
mock_hook_file = os .path .join (self .tmpdir , f'{ filename_root } .py' )
165
168
write_file (mock_hook_file , MOCK_EP_FILE )
169
+ else :
170
+ self .skipTest ("Entry points not available in this Python version" )
166
171
167
172
def tearDown (self ):
168
173
"""Clean up the test environment."""
@@ -178,24 +183,14 @@ def tearDown(self):
178
183
for idx in reversed (torm ):
179
184
del sys .meta_path [idx ]
180
185
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
-
187
186
def test_entrypoints_get_group (self ):
188
187
"""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
-
192
188
expected = {
193
189
HOOKS_ENTRYPOINT : MOCK_HOOK_EP_NAME ,
194
190
EASYBLOCK_ENTRYPOINT : MOCK_EASYBLOCK_EP_NAME ,
195
191
TOOLCHAIN_ENTRYPOINT : MOCK_TOOLCHAIN_EP_NAME ,
196
192
}
197
193
198
- # init_config()
199
194
for group in [HOOKS_ENTRYPOINT , EASYBLOCK_ENTRYPOINT , TOOLCHAIN_ENTRYPOINT ]:
200
195
epts = get_group_entrypoints (group )
201
196
self .assertIsInstance (epts , set , f"Expected set for group { group } " )
@@ -214,11 +209,6 @@ def test_entrypoints_list_easyblocks(self):
214
209
"""
215
210
Tests for list_easyblocks function with entry points enabled.
216
211
"""
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'))
222
212
txt = list_easyblocks ()
223
213
self .assertNotIn ("TestEasyBlock" , txt , "TestEasyBlock should not be listed without entry points enabled" )
224
214
@@ -230,10 +220,6 @@ def test_entrypoints_list_toolchains(self):
230
220
"""
231
221
Tests for list_toolchains function with entry points enabled.
232
222
"""
233
- if not HAVE_ENTRY_POINTS :
234
- self .skipTest ("Entry points not available in this Python version" )
235
-
236
- # init_config()
237
223
txt = list_toolchains ()
238
224
self .assertNotIn (MOCK_TOOLCHAIN , txt , f"{ MOCK_TOOLCHAIN } should not be listed without entry points enabled" )
239
225
@@ -246,9 +232,6 @@ def test_entrypoints_get_module_path(self):
246
232
"""
247
233
Tests for get_module_path function with entry points enabled.
248
234
"""
249
- if not HAVE_ENTRY_POINTS :
250
- self .skipTest ("Entry points not available in this Python version" )
251
-
252
235
module_path = get_module_path (MOCK_EASYBLOCK )
253
236
self .assertIn ('.generic.' , module_path , "Module path should contain '.generic.'" )
254
237
0 commit comments