def test_one_listgen_range(self): """ Test that it can chain a list and a generator """ gens = [[x for x in range(0, 6)], (x for x in range(6, 12))] result = [] for item in chain(*gens): result.append(item) self.assertEqual(result, list(range(0, 12)))
def test_one_list_range(self): """ Test that it can chain a single list """ gens = [[x for x in range(0, 6)]] result = [] for item in chain(*gens): result.append(item) self.assertEqual(result, list(range(0, 6)))
def test_two_list_range(self): """ Test that it can chain two lists """ gens = [[x for x in range(0, 6)], [x for x in range(6, 12)]] result = [] for item in chain(*gens): result.append(item) self.assertEqual(result, list(range(0, 12)))
def test_two_gen_range(self): """ Test that it can chain two generators """ gens = [(x for x in range(0, 6)), (x for x in range(6, 12))] result = [] for item in chain(*gens): result.append(item) self.assertEqual(result, list(range(0, 12)))
def test_three_listgen_range(self): """ Test that it can chain alternating lists and generators """ gens = [[x for x in range(0, 6)], (x for x in range(6, 12)), [x for x in range(12, 18)], (x for x in range(18, 24)), [x for x in range(24, 30)], (x for x in range(30, 36))] result = [] for item in chain(*gens): result.append(item) self.assertEqual(result, list(range(0, 36)))