Stack Tests all Need a Stack
In each test we need to create a new stack (so the tests
are independent).
That's a lot of
duplicate code
.
How to eliminate duplicate code?
def
test_new_stack_is_empty
(self):
stack = Stack(5)
self.assertTrue( stack.isEmpty() )
def
test_push_and_pop
(self):
stack = Stack(5)
stack.push("foo")
self.assertEqual("foo", stack.pop() )
self.assertTrue( stack.isEmpty() )