def test_where(self): d1 = {'a': 1, 'b': 2, 'c': 3, 'd': 33} d2 = {'a': 10, 'b': 2, 'c': 3, 'd': 8} w1 = iterators.where([d1, d2], a=10) self.assertEqual(iterators.ilen(w1), 1) w2 = iterators.where([d1, d2], b=2, c=3) self.assertEqual(iterators.ilen(w2), 2)
def test_splitlines(self): s = \ """a b c d e""" lines = misc.splitlines(s) self.assertTrue(iterators.isiterable(lines)) self.assertTrue(iterators.ilen(lines) == 5)
def test_ilen(self): self.assertTrue(iterators.ilen(range(100)) == 100) self.assertTrue(iterators.ilen(['a', 'b', 'c']) == 3) self.assertTrue(iterators.ilen([]) == 0)
def test_unique(self): it = iterators.unique([10, 20, 30, 40, 50] * 3) self.assertTrue(iterators.ilen(it) == 5)