# Path: automata/pda/stack.py
# class PDAStack(collections.namedtuple('PDAStack', ['stack'])):
#     """A PDA stack."""
# 
#     def __new__(cls, *elements):
#         """Create the new PDA stack."""
#         if len(elements) == 1:
#             stack = tuple(elements[0])
#         else:
#             stack = elements
#         return super(PDAStack, cls).__new__(cls, stack)
# 
#     def top(self):
#         """Return the symbol at the top of the stack."""
#         if self.stack:
#             return self.stack[-1]
#         else:
#             return ''
# 
#     def pop(self):
#         """
#         Pop the stack top from the stack.
# 
#         Return a new PDAStack with the new content.
#         """
#         stack_contents = list(self.stack)
#         stack_contents.pop()
#         return self.__class__(stack_contents)
# 
#     def replace(self, symbols):
#         """
#         Replace the top of the stack with the given symbols.
# 
#         Return a new PDAStack with the new content.
#         The first symbol in the given sequence becomes the new stack top.
#         """
#         stack_contents = list(self.stack)
#         stack_contents.pop()
#         stack_contents.extend(reversed(symbols))
#         return self.__class__(stack_contents)
# 
#     def __len__(self):
#         """Return the number of symbols on the stack."""
#         return len(self.stack)
# 
#     def __iter__(self):
#         """Return an interator for the stack."""
#         return iter(self.stack)
# 
#     def __repr__(self):
#         """Return a string representation of the stack."""
#         return '{}{}'.format(self.__class__.__name__, self.stack)


import nose.tools as nose
import tests.test_pda as test_pda
from automata.pda.stack import PDAStack
#!/usr/bin/env python3
"""Classes and functions for testing the behavior of PDAStacks."""

# from unittest.mock import patch




class TestPDAStack(test_pda.TestPDA):
    """A test class for testing stacks of pushdown automata."""

    def test_create_with_multiple_parameters(self):
        """Should create a new PDA stack with elements passed as parameters."""
        stack = PDAStack('a', 'b')
        nose.assert_equal(stack, PDAStack(('a', 'b')))

    def test_stack_iter(self):
        """Should loop through the PDA stack in some manner."""
        nose.assert_equal(list(PDAStack(['a', 'b'])), ['a', 'b'])

    def test_stack_repr(self):
        """Should create proper string representation of PDA stack."""

# Path: automata/pda/stack.py
# class PDAStack(collections.namedtuple('PDAStack', ['stack'])):
#     """A PDA stack."""
# 
#     def __new__(cls, *elements):
#         """Create the new PDA stack."""
#         if len(elements) == 1:
#             stack = tuple(elements[0])
#         else:
#             stack = elements
#         return super(PDAStack, cls).__new__(cls, stack)
# 
#     def top(self):
#         """Return the symbol at the top of the stack."""
#         if self.stack:
#             return self.stack[-1]
#         else:
#             return ''
# 
#     def pop(self):
#         """
#         Pop the stack top from the stack.
# 
#         Return a new PDAStack with the new content.
#         """
#         stack_contents = list(self.stack)
#         stack_contents.pop()
#         return self.__class__(stack_contents)
# 
#     def replace(self, symbols):
#         """
#         Replace the top of the stack with the given symbols.
# 
#         Return a new PDAStack with the new content.
#         The first symbol in the given sequence becomes the new stack top.
#         """
#         stack_contents = list(self.stack)
#         stack_contents.pop()
#         stack_contents.extend(reversed(symbols))
#         return self.__class__(stack_contents)
# 
#     def __len__(self):
#         """Return the number of symbols on the stack."""
#         return len(self.stack)
# 
#     def __iter__(self):
#         """Return an interator for the stack."""
#         return iter(self.stack)
# 
#     def __repr__(self):
#         """Return a string representation of the stack."""
#         return '{}{}'.format(self.__class__.__name__, self.stack)


# Path: tests/test_pdastack.py
import nose.tools as nose
import tests.test_pda as test_pda
from automata.pda.stack import PDAStack

#!/usr/bin/env python3
"""Classes and functions for testing the behavior of PDAStacks."""

# from unittest.mock import patch




class TestPDAStack(test_pda.TestPDA):
    """A test class for testing stacks of pushdown automata."""

    def test_create_with_multiple_parameters(self):
        """Should create a new PDA stack with elements passed as parameters."""
        stack = PDAStack('a', 'b')
        nose.assert_equal(stack, PDAStack(('a', 'b')))

    def test_stack_iter(self):
        """Should loop through the PDA stack in some manner."""
        nose.assert_equal(list(PDAStack(['a', 'b'])), ['a', 'b'])

    def test_stack_repr(self):
        """Should create proper string representation of PDA stack."""

        stack = PDAStack(['a', 'b'])