import nose  # This is the unit testing module
from stack import *

'''Test class Stack.'''

def testEmpty():
    '''Check wether a new stack is empty.'''
    s = UpStack()
    assert s.isEmpty(), 'A new stack should be empty'
    
def testTopOne():
    '''Check whether pushing an item makes it appear at the top.'''
    s = UpStack()
    s.push('a')
    top = s.peek()
    assert top == 'a', \
           'The item at the top should have been an "a" but was ' + top

def testPushPopOne():
    '''Check whether pushing an item and popping it work.'''
    s = UpStack()
    s.push('a')
    top = s.pop()
    assert top == 'a', \
           'The item at the top should have been an "a" but was ' + top


def testPushPopTwo():
    '''Check whether pushing two items and popping them work.'''
    s = UpStack()
    s.push('a')
    s.push('b')
    top1 = s.pop()
    assert top1 == 'b', \
           'The item at the top should have been a "b" but was ' + top1
    top2 = s.pop()
    assert top2 == 'a', \
           'The item at the top should have been an "a" but was ' + top2

nose.runmodule()
