def test_iter_splitchunks_linesize_over_limit(self): "Tests small_chunks" chunk_size = 5 chunks = self.chunks(chunk_size, '0405996654\n0405996653\n0405996652') entries = list( chunktools.iter_splitchunks(chunks, '\n', ChunkToolsTestCase.filter, limit=10)) self.assertListEqual(['0405996654', '0405996653', '0405996652'], entries) chunks = self.chunks(chunk_size, '7777788888\n9999900000555\n1111122222') with self.assertRaises(ValueError) as error: list( chunktools.iter_splitchunks(chunks, '\n', ChunkToolsTestCase.filter, limit=10)) self.assertEqual(str(error.exception), 'line length is over %d characters' % 10)
def test_iter_splitchunks_size_1(self): "Tests small_chunks." self.assertFilteredEntries([ *chunktools.iter_splitchunks( self.chunks(chunk_size=1), '\n', ChunkToolsTestCase.filter, ) ])
def test_iter_splitchunks_size_under_linesize(self): "Tests small_chunks" chunk_size = 5 entries = list( chunktools.iter_splitchunks(self.chunks(chunk_size), '\n', ChunkToolsTestCase.filter)) self.assertFilteredEntries(entries)
def test_iter_splitchunks_nbytes_key_chunk_limits(self): chunks = ['1234\r', '\n5678', '9012\r\n', '345\r\n', '12'] entries = [ *chunktools.iter_splitchunks(chunks, '\r\n', ChunkToolsTestCase.filter) ] self.assertListEqual(['1234', '56789012', '345', '12'], entries)
def test_iter_splitchunks_nbytes_key(self): data = self.DATA_WINDOWS self.assertFilteredEntries([ *chunktools.iter_splitchunks( self.chunks(5, data), '\r\n', ChunkToolsTestCase.filter, ) ]) self.assertFilteredEntries([ *chunktools.iter_splitchunks( self.chunks(len(data) / 2, data), '\r\n', ChunkToolsTestCase.filter, ) ]) self.assertFilteredEntries([ *chunktools.iter_splitchunks( self.chunks(len(data) * 2, data), '\r\n', ChunkToolsTestCase.filter, ), ])
def test_iter_splitchunks_one_chunk(self): "Test with one chunk." chunk_size = len(self.DATA_UNIX) * 2 self.assertFilteredEntries([ *chunktools.iter_splitchunks( self.chunks(chunk_size), '\n', ChunkToolsTestCase.filter, ), ])
def test_iter_splitchunks_size_over_linesize(self): "Test big_chunks." chunk_size = len(self.DATA_UNIX) / 2 self.assertFilteredEntries([ *chunktools.iter_splitchunks( self.chunks(chunk_size), '\n', ChunkToolsTestCase.filter, ) ])
def test_iter_splitchunks_one_chunk(self): "Test with one chunk" chunk_size = len(self.DATA_UNIX) * 2 entries = list( chunktools.iter_splitchunks(self.chunks(chunk_size), '\n', ChunkToolsTestCase.filter)) self.assertFilteredEntries(entries)
def test_iter_splitchunks_no_filter(self): self.assertSplitEntries([ *chunktools.iter_splitchunks(self.chunks(5), '\n', None), ])
def test_iter_splitchunks_no_filter(self): entries = list(chunktools.iter_splitchunks(self.chunks(5), '\n', None)) self.assertSplitEntries(entries)