예제 #1
0
    def test_it_should_count_the_number_of_occurrences_in_the_stream(self):
        stream = Stream(xrange(100))
        stream = stream.limit(50)
        self.assertEqual(stream.count(), 50)

        stream = Stream(xrange(100))
        stream = stream.limit(1000)
        self.assertEqual(stream.count(), 100)
예제 #2
0
    def test_it_should_limit_the_size_of_the_stream(self):
        stream = Stream(xrange(10000000000))
        limited = stream.limit(10)
        self.assertListEqual(list(limited), list(xrange(10)))

        stream = Stream(xrange(100))
        stream = stream.limit(1000)
        self.assertListEqual(list(stream), list(xrange(100)))
예제 #3
0
    def test_limit(self):
        stream = Stream(xrange(100))
        stream = stream.limit(50)
        self.assertEqual(stream.count(), 50)

        stream = Stream(xrange(100))
        stream = stream.limit(1000)
        self.assertEqual(stream.count(), 100)
예제 #4
0
    def test_it_should_limit_the_size_of_the_stream(self):
        stream = Stream(xrange(10000000000))
        limited = stream.limit(10)
        self.assertListEqual(list(limited), list(xrange(10)))

        stream = Stream(xrange(100))
        stream = stream.limit(1000)
        self.assertListEqual(list(stream), list(xrange(100)))
예제 #5
0
    def test_it_should_count_the_number_of_occurrences_in_the_stream(self):
        stream = Stream(xrange(100))
        stream = stream.limit(50)
        self.assertEqual(stream.count(), 50)

        stream = Stream(xrange(100))
        stream = stream.limit(1000)
        self.assertEqual(stream.count(), 100)
예제 #6
0
    def test_it_should_filter_items(self):
        stream = Stream(range(10))
        stream = stream.filter(lambda item: item % 2)
        self.assertEqual(stream.sum(), 25)

        stream = Stream(dict((v, v) for v in xrange(100)))
        stream = stream.filter(lambda kv: kv[0] % 2)
        stream = stream.filter(lambda kv: kv[0] % 10, parallel=6)
        stream = stream.limit(5).keys()
        stream = list(stream)
        self.assertListEqual(list(stream), [1, 3, 5, 7, 9])
예제 #7
0
    def test_it_should_filter_items(self):
        stream = Stream(range(10))
        stream = stream.filter(lambda item: item % 2)
        self.assertEqual(stream.sum(), 25)

        stream = Stream(dict((v, v) for v in xrange(100)))
        stream = stream.filter(lambda kv: kv[0] % 2)
        stream = stream.filter(lambda kv: kv[0] % 10, parallel=6)
        stream = stream.limit(5).keys()
        stream = list(stream)
        self.assertListEqual(list(stream), [1, 3, 5, 7, 9])