Beispiel #1
0
 def test_no_pad(self):
     xform = xf.partition(2)
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4, 5])),
                      [(1, 2), (3, 4)])
Beispiel #2
0
 def test_no_pad_empty(self):
     xform = xf.partition(2)
     self.assertEqual(list(xf.xiter(xform, [])), [])
Beispiel #3
0
 def test_reduced_last_element(self):
     xform = xf.comp(xf.partition(3, 3, ['pad', 'pad']), xf.take(2))
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])),
                      [(1, 2, 3), (4, 'pad', 'pad')])
Beispiel #4
0
 def test_complete(self):
     xform = xf.comp(xf.partition(2), xf.partition_all(10))
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])),
                      [((1, 2), (3, 4),)])
Beispiel #5
0
 def test_pad_with_iterator(self):
     xform = xf.partition(3, 3, iter(['pad', 'pad']))
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])),
                      [(1, 2, 3), (4, 'pad', 'pad')])
Beispiel #6
0
 def test_pad_too_large(self):
     xform = xf.partition(3, 3, ['pad'] * 5)
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])),
                      [(1, 2, 3), (4, 'pad', 'pad')])
Beispiel #7
0
 def test_pad_not_iter(self):
     with self.assertRaises(TypeError):
         xform = xf.partition(2, 2, 1)
         list(xf.xiter(xform, [1, 2, 3]))
Beispiel #8
0
 def test_step_neg(self):
     with self.assertRaises(ValueError):
         xf.partition(1, -1)
Beispiel #9
0
 def test_step_zero(self):
     with self.assertRaises(ValueError):
         xf.partition(1, 0)
Beispiel #10
0
 def test_step_fraction(self):
     with self.assertRaises(ValueError):
         xf.partition(1, 1.5)
Beispiel #11
0
 def test_step_pos(self):
     xform = xf.partition(2, 1)
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3])), [(1, 2), (2, 3)])