File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
astroid/interpreter/_import Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -325,6 +325,11 @@ def find_module(
325
325
submodule_search_locations = path ,
326
326
)
327
327
328
+ def contribute_to_path (
329
+ self , spec : ModuleSpec , processed : list [str ]
330
+ ) -> Sequence [str ] | None :
331
+ return spec .submodule_search_locations
332
+
328
333
329
334
class PathSpecFinder (Finder ):
330
335
"""Finder based on importlib.machinery.PathFinder."""
Original file line number Diff line number Diff line change @@ -284,6 +284,17 @@ def test_ast_from_module_name_pyz(self) -> None:
284
284
finally :
285
285
os .remove (linked_file_name )
286
286
287
+ def test_ast_from_module_name_pyz_with_submodule (self ) -> None :
288
+ with self ._restore_package_cache ():
289
+ archive_path = os .path .join (resources .RESOURCE_PATH , "x.zip" )
290
+ sys .path .insert (0 , archive_path )
291
+ module = self .manager .ast_from_module_name ("xxx.test" )
292
+ self .assertEqual (module .name , "xxx.test" )
293
+ end = os .path .join (archive_path , "xxx" , "test" )
294
+ self .assertTrue (
295
+ module .file .endswith (end ), f"{ module .file } doesn't endswith { end } "
296
+ )
297
+
287
298
def test_zip_import_data (self ) -> None :
288
299
"""Check if zip_import_data works."""
289
300
with self ._restore_package_cache ():
You can’t perform that action at this time.
0 commit comments