Example #1
0
 def test_powerset(self):
     it = iterators.powerset(xrange(3))
     self.assertTrue(iterators.isiterable(it))
     lst = list(it)
     self.assertTrue(
         lst == [(), (0,), (1,), (2,), (0, 1), (0, 2), (1, 2), (0, 1, 2)]
     )
Example #2
0
    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)
Example #3
0
 def test_isiterable(self):
     self.assertTrue(iterators.isiterable([]))
     self.assertTrue(iterators.isiterable([1, 2, 3]))
     self.assertTrue(iterators.isiterable(x for x in [1, 2]))
     self.assertFalse(iterators.isiterable(1))
     self.assertFalse(iterators.isiterable('string', strings=False))
     self.assertTrue(iterators.isiterable('string', strings=True))
Example #4
0
 def test_files(self):
     files = misc.files('.', '*')
     self.assertTrue(iterators.isiterable(files))
Example #5
0
 def wrapped(*args, **kwargs):
     value = func(*args, **kwargs)
     return value if isiterable(value) else [value]
Example #6
0
 def test_split(self):
     head, tail = iterators.split(range(10))
     self.assertTrue(head == 0)
     self.assertTrue(iterators.isiterable(tail))