| Total Complexity | 4 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | import unittest |
||
| 6 | class TestChunks(unittest.TestCase): |
||
| 7 | def test_chunks_generator(self): |
||
| 8 | gen = range(0, 8) |
||
| 9 | chunksize = 3 |
||
| 10 | grouped = chunks(gen, chunksize=chunksize) |
||
| 11 | |||
| 12 | expected = [(0, 1, 2), (3, 4, 5), (6, 7)] |
||
| 13 | result = list(tuple(g) for g in grouped) |
||
| 14 | |||
| 15 | self.assertEqual(expected, result) |
||
| 16 | |||
| 17 | def test_chunks_sequence(self): |
||
| 18 | seq = list(range(0, 9)) |
||
| 19 | chunksize = 3 |
||
| 20 | grouped = chunks(seq, chunksize=chunksize) |
||
| 21 | |||
| 22 | expected = [(0, 1, 2), (3, 4, 5), (6, 7, 8)] |
||
| 23 | result = [tuple(g) for g in grouped] |
||
| 24 | |||
| 25 | self.assertEqual(expected, result) |
||
| 26 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.