def setUpClass(self): zipimport._zip_directory_cache.clear() self.path = sys.path[:] self.meta_path = sys.meta_path[:] self.path_hooks = sys.path_hooks[:] sys.path_importer_cache.clear() self.modules_before = support.modules_setup()
def setUp(self): modules = support.modules_setup() self.addCleanup(support.modules_cleanup, *modules) data_path = Path(self.ZIP_MODULE.__file__) data_dir = data_path.parent self.source_zip_path = data_dir / 'ziptestdata.zip' self.zip_path = Path.cwd() / '{}.zip'.format(uuid.uuid4()) self.zip_path.write_bytes(self.source_zip_path.read_bytes()) sys.path.append(str(self.zip_path)) self.data = import_module('ziptestdata')
def test_sundry(self): old_modules = support.modules_setup() try: for fn in os.listdir(scriptsdir): if not fn.endswith('.py'): continue name = fn[:-3] if name in self.skiplist: continue import_tool(name) finally: # Unload all modules loaded in this test support.modules_cleanup(*old_modules)
def setUp(self): modules = support.modules_setup() self.addCleanup(support.modules_cleanup, *modules)
def setUp(self): self.root = None self.pkgname = None self.syspath = list(sys.path) self.modules_before = support.modules_setup()
def setUp(self): self.path = sys.path[:] self.meta_path = sys.meta_path[:] self.path_hooks = sys.path_hooks[:] sys.path_importer_cache.clear() self.modules_before = support.modules_setup()
"""Having accessed resources in a zip file should not keep an open reference to the zip. """ ZIP_MODULE = zipdata01 def setUp(self): <<<<<<< HEAD modules = import_helper.modules_setup() self.addCleanup(import_helper.modules_cleanup, *modules) data_path = pathlib.Path(self.ZIP_MODULE.__file__) data_dir = data_path.parent self.source_zip_path = data_dir / 'ziptestdata.zip' self.zip_path = pathlib.Path('{}.zip'.format(uuid.uuid4())).absolute() ======= modules = support.modules_setup() self.addCleanup(support.modules_cleanup, *modules) data_path = Path(self.ZIP_MODULE.__file__) data_dir = data_path.parent self.source_zip_path = data_dir / 'ziptestdata.zip' self.zip_path = Path.cwd() / '{}.zip'.format(uuid.uuid4()) >>>>>>> 3.9 self.zip_path.write_bytes(self.source_zip_path.read_bytes()) sys.path.append(str(self.zip_path)) self.data = import_module('ziptestdata') def tearDown(self): try: sys.path.remove(str(self.zip_path)) except ValueError:
def setUp(self): modules = modules_setup() self.addCleanup(modules_cleanup, *modules)