MCPcopy Index your code
hub / github.com/RustPython/RustPython / __init__

Method __init__

Lib/test/test_importlib/util.py:229–252  ·  view source on GitHub ↗
(self, *names, module_code={})

Source from the content-addressed store, hash-verified

227 """Base class to help with creating importer mocks."""
228
229 def __init__(self, *names, module_code={}):
230 self.modules = {}
231 self.module_code = {}
232 for name in names:
233 if not name.endswith('.__init__'):
234 import_name = name
235 else:
236 import_name = name[:-len('.__init__')]
237 if '.' not in name:
238 package = None
239 elif import_name == name:
240 package = name.rsplit('.', 1)[0]
241 else:
242 package = import_name
243 module = types.ModuleType(import_name)
244 module.__loader__ = self
245 module.__file__ = '<mock __file__>'
246 module.__package__ = package
247 module.attr = name
248 if import_name != name:
249 module.__path__ = ['<mock __path__>']
250 self.modules[import_name] = module
251 if import_name in module_code:
252 self.module_code[import_name] = module_code[import_name]
253
254 def __getitem__(self, name):
255 return self.modules[name]

Callers

nothing calls this directly

Calls 3

lenFunction · 0.85
endswithMethod · 0.45
rsplitMethod · 0.45

Tested by

no test coverage detected