Line | |
---|
1 | import unittest |
---|
2 | from waeup.uniben.scripts import partition |
---|
3 | |
---|
4 | |
---|
5 | class TestScripts(unittest.TestCase): |
---|
6 | |
---|
7 | def test_partition(self): |
---|
8 | # partition() delivers the chunk sizes we expect |
---|
9 | container = [1, ] * 1000 |
---|
10 | # we can get equally sized chunks |
---|
11 | self.assertEqual(partition(container, 250), [ |
---|
12 | (0, 0, 249), (1, 250, 499), (2, 500, 749), (3, 750, 999), ] |
---|
13 | ) |
---|
14 | # the last chunk might be shorter |
---|
15 | self.assertEqual(partition(container, 400), [ |
---|
16 | (0, 0, 399), (1, 400, 799), (2, 800, 999)] |
---|
17 | ) |
---|
18 | # we get one chunk if part_size > container size |
---|
19 | self.assertEqual(partition(container, 1100), [ |
---|
20 | (0, 0, 999)] |
---|
21 | ) |
---|
Note: See
TracBrowser for help on using the repository browser.