Beispiel #1
0
    def test_generates_nothing(self):
        def generates_nothing():
            for _ in ():
                yield

        self.assertIs(generates(generates_nothing()), None)
        self.assertRaises(StopIteration, lambda: next(generates_nothing()))
Beispiel #2
0
    def test_generates_nothing(self):

        def generates_nothing():
            for _ in ():
                yield

        self.assertIs(generates(generates_nothing()), None)
        self.assertRaises(StopIteration, lambda : next(generates_nothing()))
Beispiel #3
0
    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])
Beispiel #4
0
    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])
Beispiel #5
0
    def test_generates_single(self):
        def generates_single():
            yield 'foo'

        self.assert_iter_equal(generates(generates_single()), ['foo'])
Beispiel #6
0
    def test_generates_single(self):

        def generates_single():
            yield 'foo'

        self.assert_iter_equal(generates(generates_single()), ['foo'])