示例#1
0
 def test_three_item_iterable_sends_three_items(self):
     items = [4, 7, 2, 1, 4]
     collection = CollectingSink()
     sink = collection()
     poisson_source(1e6, items, sink)
     result = list(collection)
     self.assertListEqual(result, items)
示例#2
0
 def test_three_item_iterable_sends_three_items(self):
     items = [4, 7, 2, 1, 4]
     collection = CollectingSink()
     sink = collection()
     poisson_source(1e6, items, sink)
     result = list(collection)
     self.assertListEqual(result, items)
示例#3
0
 def test_non_positive_rate_raises_value_error(self):
     with self.assertRaises(ValueError):
         poisson_source(0.0, [], None)
示例#4
0
 def test_all_consumed_exits_with_empty_iterator(self):
     items = [4, 7, 2, 1, 4]
     collection = CollectingSink()
     sink = collection()
     remaining = poisson_source(1e6, items, sink)
     self.assertIsNone(iterator_or_none(remaining))
示例#5
0
 def test_closed_target_exits_with_remaining_items(self):
     items = [4, 7, 2, 1, 4]
     collection = SingularSink()
     sink = collection()
     remaining = poisson_source(1e6, items, sink)
     self.assertListEqual(list(remaining), [7, 2, 1, 4])
示例#6
0
 def test_empty_iterable_sends_no_items(self):
     collection = CollectingSink()
     sink = collection()
     poisson_source(1e6, [], sink)
     self.assertEqual(len(collection), 0)
示例#7
0
 def test_non_positive_rate_raises_value_error(self):
     with self.assertRaises(ValueError):
         poisson_source(0.0, [], None)
示例#8
0
 def test_all_consumed_exits_with_empty_iterator(self):
     items = [4, 7, 2, 1, 4]
     collection = CollectingSink()
     sink = collection()
     remaining = poisson_source(1e6, items, sink)
     self.assertIsNone(iterator_or_none(remaining))
示例#9
0
 def test_closed_target_exits_with_remaining_items(self):
     items = [4, 7, 2, 1, 4]
     collection = SingularSink()
     sink = collection()
     remaining = poisson_source(1e6, items, sink)
     self.assertListEqual(list(remaining), [7, 2, 1, 4])
示例#10
0
 def test_empty_iterable_sends_no_items(self):
     collection = CollectingSink()
     sink = collection()
     poisson_source(1e6, [], sink)
     self.assertEqual(len(collection), 0)