def test_raises_stop_iteration(self): iterator = asynchronous.UseOnceIterator([]) self.assertRaises(StopIteration, iterator.__next__)
def test_raises_iterator_reused(self): iterator = asynchronous.UseOnceIterator([]) # Loop over the iterator to get to the point where we might try # and reuse it. list(iterator) self.assertRaises(IteratorReusedError, iterator.__next__)
def test_returns_correct_items_for_list(self): expected_values = list(range(10)) iterator = asynchronous.UseOnceIterator(expected_values) actual_values = [val for val in iterator] self.assertEqual(expected_values, actual_values)