def setUp(self): self.temp_filename = "".join( random.choice("abcdefghijklmnopqrstuvwxyz") for _ in range(6)) + ".zip" self.temp_filename = os.path.join(tempfile.gettempdir(), self.temp_filename) archive_fs = archivefs.ArchiveFS(self.temp_filename, format='zip', mode='w') def makefile(filename, contents): if dirname(filename): archive_fs.makedir(dirname(filename), recursive=True, allow_recreate=True) f = archive_fs.open(filename, 'wb') f.write(contents) f.close() makefile("a.txt", b("Hello, World!")) makefile("b.txt", b("b")) makefile( u"\N{GREEK SMALL LETTER ALPHA}/\N{GREEK CAPITAL LETTER OMEGA}.txt", b("this is the alpha and the omega")) makefile("foo/bar/baz.txt", b("baz")) makefile("foo/second.txt", b("hai")) archive_fs.close()
def setUp(self): self.temp_filename = "".join(random.choice("abcdefghijklmnopqrstuvwxyz") for _ in range(6))+".zip" self.temp_filename = os.path.join(tempfile.gettempdir(), self.temp_filename) self.zf = zipfile.ZipFile(self.temp_filename, "w") zf = self.zf zf.writestr("a.txt", b("Hello, World!")) zf.writestr("b.txt", b("b")) zf.writestr("1.txt", b("1")) zf.writestr("foo/bar/baz.txt", b("baz")) zf.writestr("foo/second.txt", b("hai")) zf.close() self.fs = archivefs.ArchiveFS(self.temp_filename, "r")