Exemplo n.º 1
0
 def test_take_peeked(self) -> None:
     it = PeekingIterator(range(2))
     self.assertEqual(0, it.peek())
     it.take_peeked(0)
     self.assertEqual(1, next(it))
     with self.assertRaises(StopIteration):
         next(it)
Exemplo n.º 2
0
 def test_take_peeked_wrong_value(self) -> None:
     it = PeekingIterator(range(2))
     self.assertEqual(0, it.peek())
     with self.assertRaisesRegex(
             AssertionError, 'expected the peaked value to be the same'):
         it.take_peeked(1)
     it.take_peeked(0)
     self.assertEqual(1, next(it))