def test_pop(): letters = Stack() letters.push('A') letters.push('B') letters.push('C') assert letters.pop() == 'C'
def test_push_onto_empty(): s = Stack() s.push("apple") actual = s.top.value expected = "apple" assert actual == expected
def test_stack_push(): s = Stack() s.push('hello world') assert s.top.value == 'hello world'
def test_stacks_and_queues_1 (): stack = Stack() stack.push('a') actual = stack.top.value expected = 'a' assert actual == expected
def test_stacks_and_queues_7 (): stack = Stack() actual = stack.pop() expected = None assert actual == expected
def test_instantiate_empty_stack(): stack = Stack() actual = stack.isEmpty() assert actual
def test_pop_or_peek_empty_stack(): stack = Stack() with pytest.raises(EmptyStackException): stack.peek() with pytest.raises(EmptyStackException): stack.pop()
def test_stack_top(): stack1 = Stack() assert stack1.top == None
def test_stack_str(): stack9 = Stack() stack9.push(5) assert str(stack9) == "[5]"
def test_stack_peek(): stack5 = Stack() stack5.push(5) assert stack5.peek() == 5 assert stack5.top.val == 5
def test_stack_is_empty(): stack6 = Stack() assert stack6.is_empty() == True stack6.push(5) assert stack6.is_empty() == False
def test_stack_pop_exception(): stack4 = Stack() with pytest.raises(Exception) as excep: stack4.pop() assert "EmptyStack" in excep
def test_stack_pop(): stack3 = Stack() stack3.push(0) assert stack3.pop() == 0 assert stack3.top == None
def test_stack_push(): stack2 = Stack() stack2.push(0) assert stack2.top.val == 0
def test_peek_on_empty_raises_exception(): new_stack = Stack() expected = 'Exception' actual = new_stack.peek() assert expected == actual
def test_instantiation_empty(self): assert Stack()
def test_pop_empty(): s = Stack() with pytest.raises(InvalidOperationError) as e: s.pop() assert str(e.value) == "Method not allowed on empty collection"
def stack(self): return Stack()
def test_stack_push(): expected = "pass" stack = Stack() stack.push("pass") actual = f"{stack}" assert actual == expected
from stacks_and_queues.stacks_and_queues import Stack class PseudoQueue(): def __init__(self): self.stack1 = Stack() self.stack2 = Stack() def enqueue(self, value): self.stack1.push(value) def dequeue(self): while self.stack1.peek(): if self.stack1.top.next == None: return self.stack1.top.value else: temp = self.stack1.pop() self.stack2.push(temp) continue if __name__ == "__main__": new_stack = Stack() new_stack.push("10") new_stack.push("15") new_stack.push("20") # new_stack.pop() # new_stack.pop() print(new_stack)
def __init__(self): self.input_stack = Stack() self.output = Stack()
def __init__(self): self.stack1 = Stack() self.stack2 = Stack()
def test_stacks_and_queues_6 (): stack = Stack() actual = stack.top expected = None assert actual == expected
def __init__(self): self.front_stack = Stack() self.rear_stack = Stack() self.front = self.rear = None
def test_pop_single(): s = Stack() s.push("apple") actual = s.pop() expected = "apple" assert actual == expected
def test_can_successfully_instantiate_an_empty_stack(): new_stack = Stack() expected = None actual = new_stack.top assert expected == actual
def test_pop_empty(): s = Stack() with pytest.raises(InvalidOperationError) as e: s.pop() assert str(e.value) == "Not allowed on empty structure"
def test_can_successfully_push_to_a_stack(): new_stack = Stack() new_stack.push('blue') expected = 'blue' actual = new_stack.peek() assert expected == actual
def test_stack_push_many(): s = Stack() s.push('hello world') s.push('multiple values woah') assert s.top.value == 'multiple values woah'
def test_push_many(): letters = Stack() letters.push('A') letters.push('B') letters.push('C') assert print_all(letters) == 'C; B; A; '