comparison tests/test_chunk.py @ 18:56596902e9ae default tip

add some setup + tests
author Jeff Hammel <k0scist@gmail.com>
date Sun, 10 Dec 2017 17:57:03 -0800
parents
children
comparison
equal deleted inserted replaced
17:4793f99b73e0 18:56596902e9ae
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()