def test_current(): stack = Stack() assert_true(stack.current is _undefined) stack.push('foo') assert_equal(stack.current, 'foo') stack.pop() assert_true(stack.current is _undefined) stack.push('foo, part 2') stack.flush() assert_true(stack.current is _undefined) stack = Stack(['foo', 'bar', 'baz']) assert_equal(stack.current, 'baz')
def test_pop(): stack = Stack(['foo']) assert_equal(stack.current, 'foo') assert_equal(stack.pop(), 'foo') assert_equal(stack.current, _undefined) assert_raises(StackEmpty, stack.pop)