source: main/waeup.uniben/trunk/src/waeup/uniben/tests/test_scripts.py @ 16536

Last change on this file since 16536 was 13192, checked in by uli, 9 years ago

Add tests for scripts.

File size: 706 bytes
Line 
1import unittest
2from waeup.uniben.scripts import partition
3
4
5class 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.