|
4 | 4 |
|
5 | 5 |
|
6 | 6 | def test_batch_items_basic(): |
7 | | - items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
8 | | - batches = list(batch_items(items, 3)) |
| 7 | + batches = list(batch_items([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3)) |
9 | 8 |
|
10 | | - assert len(batches) == 4 |
11 | | - assert batches[0] == [1, 2, 3] |
12 | | - assert batches[1] == [4, 5, 6] |
13 | | - assert batches[2] == [7, 8, 9] |
14 | | - assert batches[3] == [10] |
| 9 | + assert batches == [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] |
15 | 10 |
|
16 | 11 |
|
17 | 12 | def test_batch_items_exact_fit(): |
18 | | - items = [1, 2, 3, 4, 5, 6] |
19 | | - batches = list(batch_items(items, 3)) |
| 13 | + batches = list(batch_items([1, 2, 3, 4, 5, 6], 3)) |
20 | 14 |
|
21 | | - assert len(batches) == 2 |
22 | | - assert batches[0] == [1, 2, 3] |
23 | | - assert batches[1] == [4, 5, 6] |
| 15 | + assert batches == [[1, 2, 3], [4, 5, 6]] |
24 | 16 |
|
25 | 17 |
|
26 | 18 | def test_batch_items_single_batch(): |
27 | | - items = [1, 2, 3] |
28 | | - batches = list(batch_items(items, 10)) |
| 19 | + batches = list(batch_items([1, 2, 3], 10)) |
29 | 20 |
|
30 | | - assert len(batches) == 1 |
31 | | - assert batches[0] == [1, 2, 3] |
| 21 | + assert batches == [[1, 2, 3]] |
32 | 22 |
|
33 | 23 |
|
34 | 24 | def test_batch_items_empty_list(): |
35 | | - items = [] |
36 | | - batches = list(batch_items(items, 5)) |
| 25 | + batches = list(batch_items([], 5)) |
37 | 26 |
|
38 | | - assert len(batches) == 0 |
| 27 | + assert batches == [] |
39 | 28 |
|
40 | 29 |
|
41 | 30 | def test_batch_items_size_one(): |
42 | | - items = [1, 2, 3, 4, 5] |
43 | | - batches = list(batch_items(items, 1)) |
| 31 | + batches = list(batch_items([1, 2, 3, 4, 5], 1)) |
44 | 32 |
|
45 | | - assert len(batches) == 5 |
46 | | - assert batches[0] == [1] |
47 | | - assert batches[1] == [2] |
48 | | - assert batches[2] == [3] |
49 | | - assert batches[3] == [4] |
50 | | - assert batches[4] == [5] |
| 33 | + assert batches == [[1], [2], [3], [4], [5]] |
51 | 34 |
|
52 | 35 |
|
53 | 36 | def test_batch_items_strings(): |
54 | | - items = ["a", "b", "c", "d", "e", "f", "g"] |
55 | | - batches = list(batch_items(items, 3)) |
| 37 | + batches = list(batch_items(["a", "b", "c", "d", "e", "f", "g"], 3)) |
56 | 38 |
|
57 | | - assert len(batches) == 3 |
58 | | - assert batches[0] == ["a", "b", "c"] |
59 | | - assert batches[1] == ["d", "e", "f"] |
60 | | - assert batches[2] == ["g"] |
| 39 | + assert batches == [["a", "b", "c"], ["d", "e", "f"], ["g"]] |
0 commit comments