예제 #1
0
    def test_last(self):
        s = StringList(initial=["A", "list", "of", "strings"])
        self.assertEqual(s.last, "strings")

        with self.assertRaises(IndexError):
            s.pop()
            s.pop()
            s.pop()
            s.pop()
            s.last
예제 #2
0
    def test_pop(self):
        s = StringList(initial=["A", "list", "of", "strings"])
        s1 = s.pop()
        self.assertTrue(len(s) == 3)
        self.assertTrue(s1 == "strings")

        s1 = s.pop()
        self.assertTrue(len(s) == 2)
        self.assertTrue(s1 == "of")

        s1 = s.pop()
        self.assertTrue(len(s) == 1)
        self.assertTrue(s1 == "list")

        s1 = s.pop()
        self.assertTrue(len(s) == 0)
        self.assertTrue(s1 == "A")

        with self.assertRaises(IndexError):
            s.pop()