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)
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)
def test_divisibleby(self): stream = Stream(xrange(2000)) stream = stream.ints().divisible_by(10) self.assertEqual(stream.count(), 200) stream = Stream(xrange(2000)) stream = stream.divisible_by(1000) self.assertEquals(list(stream), [0, 1000])
def test_it_should_filter_by_divisibility(self): stream = Stream(range(6)) stream = stream.divisible_by(2) self.assertListEqual(list(stream), [0, 2, 4]) stream = Stream(xrange(2000)) stream = stream.ints().divisible_by(10) self.assertEqual(stream.count(), 200) stream = Stream(xrange(2000)) stream = stream.divisible_by(1000) self.assertEquals(list(stream), [0, 1000])
def test_first(self): stream = Stream(xrange(10)) self.assertEqual(stream.first, 0) self.assertEqual(stream.first, 0) self.assertEqual(stream.first, 0) self.assertEqual(stream.count(), 10)