示例#1
0
 def test_arity_zero(self):
     self.assertEqual(xf.take_nth(1)(lambda: 'success')(), 'success')
示例#2
0
 def test_complete(self):
     xform = xf.comp(xf.take_nth(1), xf.partition_all(2))
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3])), [(1, 2), (3,)])
示例#3
0
 def test_take_nega(self):
     with self.assertRaises(ValueError):
         xf.take_nth(-1)
示例#4
0
 def test_reduced(self):
     xform = xf.comp(xf.take_nth(3), xf.take(2))
     self.assertEqual(list(xf.xiter(xform, range(12))), [0, 3])
示例#5
0
 def test_take_zero(self):
     with self.assertRaises(ValueError):
         xf.take_nth(0)
示例#6
0
 def test_take_fraction(self):
     with self.assertRaises(ValueError):
         xf.take_nth(1.5)
示例#7
0
 def test_empty(self):
     xform = xf.take_nth(1)
     self.assertEqual(list(xf.xiter(xform, [])), [])
示例#8
0
 def test_take_few(self):
     xform = xf.take_nth(3)
     self.assertEqual(list(xf.xiter(xform, range(12))), [0, 3, 6, 9])
示例#9
0
 def test_take_every(self):
     xform = xf.take_nth(1)
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])), [1, 2, 3, 4])