Beispiel #1
0
 def test_createWithLines(self):
     """
     Verify that a history object can be created with an initial set of
     lines.
     """
     h = History(["a", "b"])
     self.assertEqual(h.allLines(), ["a", "b"])
Beispiel #2
0
 def test_allLinesWhenEmpty(self):
     """
     Verify that retrieving all lines at once from an empty history object
     returns an empty list.
     """
     h = History()
     self.assertEqual(h.allLines(), [])
Beispiel #3
0
 def test_addLineWhenEmpty(self):
     """
     Verify that a line added to an empty history object results in that
     line being included in the list returned by C{allLines}.
     """
     s = "hello world"
     h = History([s])
     self.assertEqual(h.allLines(), [s])
Beispiel #4
0
 def test_addLineAtEnd(self):
     """
     Verify that, by default, a line added to a history object is added
     after any existing lines.
     """
     s1 = "hello"
     s2 = "world"
     h = History([s1])
     h.addLine(s2)
     self.assertEqual(h.allLines(), [s1, s2])
Beispiel #5
0
 def test_addLineInMiddle(self):
     """
     Verify that even if the history object is not positioned at the end,
     C{addLine} adds the line to the end.
     """
     s1 = "hello"
     s2 = "world"
     s3 = "goodbye"
     h = History([s1, s2])
     h.previousLine()
     h.addLine(s3)
     self.assertEqual(h.allLines(), [s1, s2, s3])