forked from jwarren116/data-structures
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_stack.py
More file actions
28 lines (22 loc) · 714 Bytes
/
test_stack.py
File metadata and controls
28 lines (22 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from stack import Stack
import pytest
def test_stack_push():
# Tests that "Bacon" is first item when pushed to stack
new_stack = Stack()
new_stack.push("bacon")
assert new_stack.first_item.data == "bacon"
def test_stack_push_multi():
# Tests that we can push multiple items to stack
# then get expected results from pop
new_stack = Stack()
new_stack.push("bacon")
new_stack.push("steak")
new_stack.push("grilled cheese")
new_stack.pop()
new_stack.pop()
assert new_stack.pop() == "bacon"
def test_empty_stack_pop():
# Tests that pop() on empty stack returns ValueError
new_stack = Stack()
with pytest.raises(ValueError):
new_stack.pop()