def test_add_sys_path(self): c = OxidizedResourceCollector( allowed_locations=["in-memory", "filesystem-relative"]) for path in sys.path: if os.path.isdir(path): for resource in find_resources_in_path(path): c.add_in_memory(resource) c.add_filesystem_relative("", resource) python_exe = os.environ.get("PYTHON_SYS_EXECUTABLE") with assert_tempfile_cleaned_up(): resources, file_installs = c.oxidize(python_exe=python_exe) f = OxidizedFinder() f.add_resources(resources) with (self.td / "serialized").open("wb") as fh: fh.write(f.serialize_indexed_resources()) f = OxidizedFinder() f.index_file_memory_mapped(self.td / "serialized") self.assertGreaterEqual(len(f.indexed_resources()), len(resources)) for r in f.indexed_resources(): r.in_memory_source r.in_memory_bytecode
def test_index_file_memory_mapped_simple(self): path = self.td / "simple" with path.open("wb") as fh: fh.write(self.get_resources_data()) f = OxidizedFinder() f.index_file_memory_mapped(path)
def test_index_file_memory_mapped_no_file(self): f = OxidizedFinder() with self.assertRaises(ValueError): f.index_file_memory_mapped(self.td / "does-not-exist")