def test_min_spare_cap_few(self): h = rb.MinSpareCapacity(self.bins[:3]) expected = [[8, 2], [5, 4, 1], [7]] misfits = [6] self.assertEqual(len(self.items) - len(misfits), h.binpack(self.items)) did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part) self.assertEqual(misfits, h.misfits)
def test_min_spare_cap_small(self): h = rb.MinSpareCapacity(make_bin=lambda: self.make_bin(7)) expected = [[5, 2], [7], [6, 1], [4]] misfits = [8] self.assertEqual(len(self.items) - len(misfits), h.binpack(self.items)) did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part) self.assertEqual(misfits, h.misfits)
def test_min_spare_cap_make(self): h = rb.MinSpareCapacity(make_bin=lambda: self.make_bin(10)) self.assertEqual(len(self.items), h.binpack(self.items)) expected = [[8, 2], [5], [7, 1], [6, 4]] did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part)
def test_min_spare_cap_fixed(self): h = rb.MinSpareCapacity(self.bins) self.assertEqual(len(self.items), h.binpack(self.items)) expected = [[8, 2], [5], [7, 1], [6, 4], []] did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part)