def test_repeatfunc(self): def f(): return "test" # unlimited count it = iters.repeatfunc(f) self.assertEqual("test", next(it)) self.assertEqual("test", next(it)) self.assertEqual("test", next(it)) # limited it = iters.repeatfunc(f, 2) self.assertEqual("test", next(it)) self.assertEqual("test", next(it)) self.assertRaises(StopIteration, next, it)