def test_generates_nothing(self): def generates_nothing(): for _ in (): yield self.assertIs(generates(generates_nothing()), None) self.assertRaises(StopIteration, lambda: next(generates_nothing()))
def test_generates_nothing(self): def generates_nothing(): for _ in (): yield self.assertIs(generates(generates_nothing()), None) self.assertRaises(StopIteration, lambda : next(generates_nothing()))
def test_generates_something(self): def generates_something(): i = 0 while True: yield i i += 1 self.assert_iter_equal(head(generates(generates_something()), 4), [0, 1, 2, 3])
def test_generates_single(self): def generates_single(): yield 'foo' self.assert_iter_equal(generates(generates_single()), ['foo'])