MCPcopy Index your code
hub / github.com/python/cpython / cleanup

Method cleanup

Lib/test/test_site.py:440–456  ·  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

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