def test_valid_grouping(self): got = ichunks("aaaabbbbccccdddd", 4) expected = (("a", ) * 4, ("b",) * 4, ("c",) * 4, ("d",) * 4) self.assertEqual(tuple(map(tuple, got)), expected) got = ichunks([1, 1, 1, 2, 2, 2, 3, 3, 3], 3) expected = ((1, 1, 1), (2, 2, 2), (3, 3, 3)) self.assertEqual(tuple(map(tuple, got)), expected)
def test_valid_grouping(self): got = functional.ichunks("aaaabbbbccccdddd", 4) expected = (("a", ) * 4, ("b",) * 4, ("c",) * 4, ("d",) * 4) self.assertEqual(tuple(map(tuple, got)), expected) got = functional.ichunks([1, 1, 1, 2, 2, 2, 3, 3, 3], 3) expected = ((1, 1, 1), (2, 2, 2), (3, 3, 3)) self.assertEqual(tuple(map(tuple, got)), expected)
def test_filler(self): got = ichunks("aaaabbbccccddd", 4, "-") expected = (("a", "a", "a", "a"), ("b", "b", "b", "c"), ("c", "c", "c", "d"), ("d", "d", "-", "-")) self.assertEqual(tuple(map(tuple, got)), expected) got = ichunks("aaaabbbbccccdddd", 4, None) expected = (("a", ) * 4, ("b",) * 4, ("c",) * 4, ("d",) * 4) self.assertEqual(tuple(map(tuple, got)), expected)
def test_filler(self): got = functional.ichunks("aaaabbbccccddd", 4, "-") expected = (("a", "a", "a", "a"), ("b", "b", "b", "c"), ("c", "c", "c", "d"), ("d", "d", "-", "-")) self.assertEqual(tuple(map(tuple, got)), expected) got = functional.ichunks("aaaabbbbccccdddd", 4, None) expected = (("a", ) * 4, ("b",) * 4, ("c",) * 4, ("d",) * 4) self.assertEqual(tuple(map(tuple, got)), expected)
def test_filler_None(self): got = functional.ichunks("aaaabbbccccddd", 4, None) expected = (("a", "a", "a", "a"), ("b", "b", "b", "c"), ("c", "c", "c", "d"), ("d", "d", None, None)) self.assertEqual(tuple(map(tuple, got)), expected)
def test_odd_ball_grouping(self): got = ichunks("aaabb", 3) expected = (("a",) * 3, ("b",) * 2) self.assertEqual(tuple(map(tuple, got)), expected)
def test_returns_generator_object(self): self.assertEqual(type(ichunks("aaaabbbb", 4)).__name__, "generator")
def test_odd_ball_grouping(self): got = functional.ichunks("aaabb", 3) expected = (("a",) * 3, ("b",) * 2) self.assertEqual(tuple(map(tuple, got)), expected)
def test_returns_generator_object(self): self.assertEqual(type(functional.ichunks("aaaabbbb", 4)).__name__, "generator")