MCPcopy
hub / github.com/pytest-dev/pytest / CustomImporter

Class CustomImporter

testing/test_pathlib.py:1608–1623  ·  view source on GitHub ↗

Imports the module name "com" as a namespace package. This ensures our namespace detection considers sys.meta_path, which is important to support all possible ways a module can be imported (for example editable installs).

Source from the content-addressed store, hash-verified

1606 """
1607
1608 class CustomImporter(importlib.abc.MetaPathFinder):
1609 """
1610 Imports the module name "com" as a namespace package.
1611
1612 This ensures our namespace detection considers sys.meta_path, which is important
1613 to support all possible ways a module can be imported (for example editable installs).
1614 """
1615
1616 def find_spec(
1617 self, name: str, path: Any = None, target: Any = None
1618 ) -> importlib.machinery.ModuleSpec | None:
1619 if name == "com":
1620 spec = importlib.machinery.ModuleSpec("com", loader=None)
1621 spec.submodule_search_locations = [str(com_root_2), str(com_root_1)]
1622 return spec
1623 return None
1624
1625 # Setup directories without configuring sys.path.
1626 models_py, _algorithms_py = self.setup_directories(

Callers 1

test_detect_meta_pathMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_detect_meta_pathMethod · 0.68