def test_peeks_at_next_value(self): """ Returns the next value in the iterator """ pk = PeekableInterface(iter([1, 2, 3, 4])) result = pk.peek() self.assertEqual(result, 1)
def test_returns_true_if_has_next(self): """ Returns True if there is a next value available in the iterator """ pk = PeekableInterface(iter([1, 2, 3, 4])) result = pk.has_next() self.assertTrue(result)
def test_returns_false_if_not_next_value(self): """ Returns False if there is not a nexr value in the iterator """ pk = PeekableInterface(iter([])) result = pk.has_next() self.assertFalse(result)
def test_returns_next_value(self): """ Returns the next value available in the interator """ pk = PeekableInterface(iter([1, 2, 3])) result = pk.next_value() self.assertEqual(result, 1)
def test_returns_false_has_next_after_iterating(self): """ Returns false from the has_next method after iterating to the end of the iterator """ pk = PeekableInterface(iter([1, 2, 3])) pk.has_next() one = pk.next_value() two = pk.next_value() pk.has_next() three = pk.next_value() result = pk.has_next() self.assertEqual(one, 1) self.assertEqual(two, 2) self.assertEqual(three, 3) self.assertFalse(result)
def test_returns_none_if_not_next_value(self): """ Returns None if there is no next value available in the interator """ pk = PeekableInterface(iter([1, 2, 3])) pk.next_value() pk.next_value() pk.next_value() result = pk.next_value() self.assertIsNone(result)
def test_instantiates(self): """ Instantiates a new version of the Peekable Iterface class """ pk = PeekableInterface(iter([1, 2, 3, 4])) self.assertIsInstance(pk, PeekableInterface)