def generate_file(tmp_dir, size, suffix='.tmp'): tmp = Tempfile(root_dir=tmp_dir, suffix=suffix) tmp.write(bytearray(random.randint(0, 255) for i in range(size))) tmp.close() return tmp
def generate_file(tmp_dir, start, stop): tmp = Tempfile(folder=tmp_dir) tmp.write(bytearray(map(lambda v: v % 256, range(start, stop)))) tmp.close() return tmp
def _generate_files(tmp_files, number, size): content = b'1' * size files = [] for i in range(0, number): t = Tempfile() tmp_files.append(t) t.write(content) files.append(t) return files