def test_insert_one_gig_1k_chunks_no_names_null(self): # write to dev/null so we test the pack processing. transport = self.get_transport() dev_null = open('/dev/null', 'wb') writer = pack.ContainerWriter(dev_null.write) self.write_1_gig(writer) dev_null.close()
def test_construct(self): """Test constructing a ContainerWriter. This uses None as the output stream to show that the constructor doesn't try to use the output stream. """ writer = pack.ContainerWriter(None)
def test_insert_one_gig_1k_chunks_no_names_disk(self): # test real disk writing of many small chunks. # useful for testing whether buffer sizes are right transport = self.get_transport() stream = transport.open_write_stream('pack.pack') writer = pack.ContainerWriter(stream.write) self.write_1_gig(writer) stream.close()
def test_read_skipping_records(self): pack_data = StringIO() writer = pack.ContainerWriter(pack_data.write) writer.begin() memos = [] memos.append(writer.add_bytes_record('abc', names=[])) memos.append(writer.add_bytes_record('def', names=[('name1', )])) memos.append(writer.add_bytes_record('ghi', names=[('name2', )])) memos.append(writer.add_bytes_record('jkl', names=[])) writer.end() transport = self.get_transport() transport.put_bytes('mypack', pack_data.getvalue()) requested_records = [memos[0], memos[2]] reader = pack.make_readv_reader(transport, 'mypack', requested_records) result = [] for names, reader_func in reader.iter_records(): result.append((names, reader_func(None))) self.assertEqual([([], 'abc'), ([('name2', )], 'ghi')], result)
def setUp(self): self.output = StringIO() self.writer = pack.ContainerWriter(self.output.write)
def __init__(self, fileobj): self._container = pack.ContainerWriter(self._write_encoded) self._fileobj = fileobj self._compressor = bz2.BZ2Compressor()
def setUp(self): super(TestContainerWriter, self).setUp() self.output = StringIO() self.writer = pack.ContainerWriter(self.output.write)