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

Method _add_relative_modules

Lib/test/test_runpy.py:377–398  ·  view source on GitHub ↗
(self, base_dir, source, depth)

Source from the content-addressed store, hash-verified

375 if verbose > 1: print("Package executed successfully")
376
377 def _add_relative_modules(self, base_dir, source, depth):
378 if depth <= 1:
379 raise ValueError("Relative module test needs depth > 1")
380 pkg_name = "__runpy_pkg__"
381 module_dir = base_dir
382 for i in range(depth):
383 parent_dir = module_dir
384 module_dir = os.path.join(module_dir, pkg_name)
385 # Add sibling module
386 sibling_fname = os.path.join(module_dir, "sibling.py")
387 create_empty_file(sibling_fname)
388 if verbose > 1: print(" Added sibling module:", sibling_fname)
389 # Add nephew module
390 uncle_dir = os.path.join(parent_dir, "uncle")
391 self._add_pkg_dir(uncle_dir)
392 if verbose > 1: print(" Added uncle package:", uncle_dir)
393 cousin_dir = os.path.join(uncle_dir, "cousin")
394 self._add_pkg_dir(cousin_dir)
395 if verbose > 1: print(" Added cousin package:", cousin_dir)
396 nephew_fname = os.path.join(cousin_dir, "nephew.py")
397 create_empty_file(nephew_fname)
398 if verbose > 1: print(" Added nephew module:", nephew_fname)
399
400 def _check_relative_imports(self, depth, run_name=None):
401 contents = r"""\

Callers 2

Calls 4

_add_pkg_dirMethod · 0.95
create_empty_fileFunction · 0.90
printFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected