コード例 #1
0
def test_Stack_pop_multiple_items():
    my_stack = Stack()
    my_stack.push(1)
    my_stack.push(2)
    my_stack.push(3)
    my_stack.pop()
    actual = my_stack.pop()
    expected = 2
    assert actual == expected
コード例 #2
0
def test_Stack_isEmpty_not_empty():
    my_stack = Stack()
    my_stack.push(1)
    my_stack.push(2)
    my_stack.push(3)
    actual = my_stack.is_empty()
    expected = False
    assert actual == expected
コード例 #3
0
def test_Stack_peek_top():
    my_stack = Stack()
    my_stack.push(1)
    my_stack.push(2)
    my_stack.push(3)
    actual = my_stack.peek()
    expected = 3
    assert actual == expected
コード例 #4
0
def test_Stack_pop_one_item():
    my_stack = Stack()
    my_stack.push(1)
    my_stack.push(2)
    my_stack.push(3)
    actual = my_stack.pop()
    expected = 3
    assert actual == expected
コード例 #5
0
def test_Stack_push_multiple_items():
    my_stack = Stack()
    my_stack.push(1)
    my_stack.push(2)
    my_stack.push(3)
    actual = my_stack.peek()
    expected = 3
    assert actual == expected
コード例 #6
0
def test_Stack_isEmpty_empty():
    my_stack = Stack()
    actual = my_stack.is_empty()
    expected = True
    assert actual == expected
コード例 #7
0
def test_Stack_peek_empty_Exception():
    with pytest.raises(AttributeError):
        my_stack = Stack()
        actual = my_stack.peek()
        expected = "Can't peek top from an empty stack"
        assert actual == expected
コード例 #8
0
def test_Stack_push_one_item():
    my_stack = Stack()
    my_stack.push(1)
    actual = my_stack.peek()
    expected = 1
    assert actual == expected
コード例 #9
0
def test_Stack_exists():
    assert Stack()