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)
| 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 | |
| 458 | class ImportSideEffectTests(unittest.TestCase): |
| 459 | """Test side-effects from importing 'site'.""" |
no test coverage detected