def test_nextLineWithNoLines(self): """ Verify that retrieving the next line from an empty history object returns an empty string. """ h = History() self.assertEqual(h.nextLine(), "")
def test_nextLineWithOneLine(self): """ Verify that when positioned at the beginning and containing only one line, the history object's C{nextLine} method returns an empty string. """ s = "hello" h = History([s]) while h.previousLine(): pass self.assertEqual(h.nextLine(), "")
def test_resetPosition(self): """ Verify that the position in the history object can be set to the end using the C{resetPosition} method. """ s = "hello" h = History() h.addLine(s) h.previousLine() h.resetPosition() self.assertEqual(h.nextLine(), "")
def test_nextLineWithTwoLines(self): """ Verify that when a history object contains two lines and is positioned at the beginning, C{nextLine} first returns the second line and then returns an empty string. """ s1 = "hello" s2 = "world" h = History([s1, s2]) while h.previousLine(): pass self.assertEqual(h.nextLine(), s2) self.assertEqual(h.nextLine(), "")