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

Method cleanup

Lib/test/test_site.py:442–458  ·  view source on GitHub ↗

Make sure that the .pth file is deleted, self.imported is not in sys.modules, and that both self.good_dirname and self.bad_dirname are not existing directories.

(self, prep=False)

Source from the content-addressed store, hash-verified

440 os.mkdir(self.good_dir_path)
441
442 def cleanup(self, prep=False):
443 """Make sure that the .pth file is deleted, self.imported is not in
444 sys.modules, and that both self.good_dirname and self.bad_dirname are
445 not existing directories."""
446 if os.path.exists(self.file_path):
447 os.remove(self.file_path)
448 if prep:
449 self.imported_module = sys.modules.get(self.imported)
450 if self.imported_module:
451 del sys.modules[self.imported]
452 else:
453 if self.imported_module:
454 sys.modules[self.imported] = self.imported_module
455 if os.path.exists(self.good_dir_path):
456 os.rmdir(self.good_dir_path)
457 if os.path.exists(self.bad_dir_path):
458 os.rmdir(self.bad_dir_path)
459
460class ImportSideEffectTests(unittest.TestCase):
461 """Test side-effects from importing 'site'."""

Calls 4

rmdirMethod · 0.80
existsMethod · 0.45
removeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected