18
|
1 #!/usr/bin/env python
|
|
2
|
|
3 """
|
|
4 test data chunking
|
|
5 """
|
|
6
|
|
7 import os
|
|
8 import unittest
|
|
9 from lemuriformes.chunk import chunk
|
|
10
|
|
11 class TestChunking(unittest.TestCase):
|
|
12
|
|
13 def test_range(self):
|
|
14 """test basic chunking with range function"""
|
|
15
|
|
16 data = list(range(64))
|
|
17 chunked = list(chunk(data, 10))
|
|
18 assert len(chunked) == 7
|
|
19 sizes = set([len(c) for c in
|
|
20 chunked[:-1]])
|
|
21 assert len(sizes) == 1
|
|
22 assert sizes.pop() == 10
|
|
23 reconstructed = []
|
|
24 for _chunk in chunked:
|
|
25 reconstructed.extend(_chunk)
|
|
26 assert reconstructed == list(range(64))
|
|
27
|
|
28
|
|
29 if __name__ == '__main__':
|
|
30 unittest.main()
|