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

Method _del_pkg

Lib/test/test_runpy.py:259–282  ·  view source on GitHub ↗
(self, top)

Source from the content-addressed store, hash-verified

257 return pkg_dir, mod_fname, mod_name, mod_spec
258
259 def _del_pkg(self, top):
260 for entry in list(sys.modules):
261 if entry.startswith("__runpy_pkg__"):
262 del sys.modules[entry]
263 if verbose > 1: print(" Removed sys.modules entries")
264 del sys.path[0]
265 if verbose > 1: print(" Removed sys.path entry")
266 for root, dirs, files in os.walk(top, topdown=False):
267 for name in files:
268 try:
269 os.remove(os.path.join(root, name))
270 except OSError as ex:
271 if verbose > 1: print(ex) # Persist with cleaning up
272 for name in dirs:
273 fullname = os.path.join(root, name)
274 try:
275 os.rmdir(fullname)
276 except OSError as ex:
277 if verbose > 1: print(ex) # Persist with cleaning up
278 try:
279 os.rmdir(top)
280 if verbose > 1: print(" Removed package tree")
281 except OSError as ex:
282 if verbose > 1: print(ex) # Persist with cleaning up
283
284 def _fix_ns_for_legacy_pyc(self, ns, alter_sys):
285 char_to_add = "c"

Callers 5

_check_moduleMethod · 0.95
_check_packageMethod · 0.95
test_run_nameMethod · 0.95

Calls 7

listClass · 0.85
rmdirMethod · 0.80
printFunction · 0.50
startswithMethod · 0.45
walkMethod · 0.45
removeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected