runtime
244 / 500
question 244 Testing & Code Quality · easy

Edge cases for splitting into batches

An export sends order IDs to a partner in batches. chunk(items, size) splits a list into lists of size items; the last batch may be shorter. A size below 1 is a ValueError, an empty list gives [], and the list passed in must not change. The function is correct. Write TestChunk so that broken versions are caught: concentrate on the edges.

Writeclass TestChunk(unittest.TestCase) with test methods
Rulechunk(["O1", "O2", "O3", "O4", "O5"], 2) → [["O1", "O2"], ["O3", "O4"], ["O5"]]; chunk([], 3) → []; a size of 0 or below raises ValueError

Loading your progress…

Edge cases for splitting into batches — Python practice · Runtime