"""Test module Stack."""

import unittest
from stack import Stack
# from stack2 import Stack

class StackEmptyTestCase(unittest.TestCase):
    """Test behaviour of an empty Stack."""

    def setUp(self):
        """Set up an empty stack."""
        self.stack = Stack()

    def tearDown(self):
        """Clean up."""
        self.stack = None

    def testIsEmpty(self):
        """Test is_empty() on empty Stack."""
        assert self.stack.is_empty(),\
               'is_empty returned False on an empty Stack!'

    def testPush(self):
        """Test push to empty Stack."""

        self.stack.push("foo")
        assert self.stack.pop() == "foo",\
               'Wrong item on top of the Stack! Expected "foo" here.'

class StackAllTestCase(unittest.TestCase):
    """Comprehensive tests of (non-empty) Stack."""

    def setUp(self):
        """Set up an empty stack."""
        self.stack = Stack()

    def tearDown(self):
        """Clean up."""
        self.stack = None

    def testAll(self):
        """Test pushing and popping multiple elements."""

        for item in range(20):
            self.stack.push(item)
            assert not self.stack.is_empty(),\
                   'is_empty() returned True on a non-empty Stack!'

        expect = 19
        while not self.stack.is_empty():
            assert self.stack.pop() == expect,\
                   ('Something wrong on top of the Stack! Expected ' +
                    str(expect) + '.')
            expect = expect - 1

if __name__ == '__main__':
    unittest.main(exit=False)
