def test_stack_pop_too_many(initial_size, overflow): # Arrange machine_state = MachineState(0) machine_state.stack = [42] * initial_size # Act + Assert with pytest.raises(StackUnderflowException): machine_state.pop(initial_size + overflow)
def test_stack_single_pop(): # Arrange machine_state = MachineState(0) machine_state.stack = [1, 2, 3] # Act result = machine_state.pop() # Assert assert isinstance(result, int)
def test_stack_multiple_pop_(): # Arrange machine_state = MachineState(0) machine_state.stack = [1, 2, 3] # Act a, b = machine_state.pop(2) # Assert assert a == 3 assert b == 2
def test_stack_multiple_pop(initial_stack, amount, expected): # Arrange machine_state = MachineState(0) machine_state.stack = initial_stack[:] # Act results = machine_state.pop(amount) # Assert assert results == initial_stack[-amount:][::-1] assert results == expected assert len(machine_state.stack) == len(initial_stack) - amount