def test_push_one(self): stack = ArrayStack() stack.push(1) self.assertEqual(stack.list(), [1]) self.assertEqual(stack.peek(), 1)
def test_peek_empty(self): stack = ArrayStack() with self.assertRaises(ValueError): stack.peek()
def test_peek_non_empty(self): stack = ArrayStack() stack.push(1) self.assertEqual(stack.peek(), 1)
def test_push_two(self): stack = ArrayStack() stack.push(1) stack.push(2) self.assertEqual(stack.list(), [1, 2]) self.assertEqual(stack.peek(), 2)