Exemplo n.º 1
0
  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)
Exemplo n.º 2
0
  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)
Exemplo n.º 3
0
  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)
Exemplo n.º 4
0
  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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 def test_odd_ball_grouping(self):
   got = ichunks("aaabb", 3)
   expected = (("a",) * 3, ("b",) * 2)
   self.assertEqual(tuple(map(tuple, got)), expected)
Exemplo n.º 7
0
 def test_returns_generator_object(self):
   self.assertEqual(type(ichunks("aaaabbbb", 4)).__name__, "generator")
Exemplo n.º 8
0
 def test_odd_ball_grouping(self):
   got = functional.ichunks("aaabb", 3)
   expected = (("a",) * 3, ("b",) * 2)
   self.assertEqual(tuple(map(tuple, got)), expected)
Exemplo n.º 9
0
 def test_returns_generator_object(self):
   self.assertEqual(type(functional.ichunks("aaaabbbb", 4)).__name__, "generator")