def test_pop_until_empty(self): ls = [randint(-10, 10) for _ in range(randint(1, 100))] s = Stack(ls) for i, e in enumerate(reversed(ls)): elem = s.pop() self.assertEqual(elem, e) self.assertEqual(s.size, len(ls) - (i + 1)) self.assertTrue(s.is_empty())
def test_pop_last(self): s = Stack([7]) self.assertEqual(s.pop(), 7) self.assertTrue(s.is_empty()) self.assertEqual(s.size, 0)
def test_pop_empty_stack(self): s = Stack() self.assertIsNone(s.pop())