def test_last_in_first_out(self): test_stack = UniqueStack() test_stack.push(UniqueLimitedStackTestCase.ITEM_1) test_stack.push(UniqueLimitedStackTestCase.ITEM_2) test_stack.push(UniqueLimitedStackTestCase.ITEM_3) self.assertEqual(3, test_stack.size()) self.assertEqual(UniqueLimitedStackTestCase.ITEM_3, test_stack.pop()) self.assertEqual(UniqueLimitedStackTestCase.ITEM_2, test_stack.pop()) self.assertEqual(UniqueLimitedStackTestCase.ITEM_1, test_stack.pop())
def test_base_stack_empty(self): test_stack = UniqueStack() self.assertEqual(0, test_stack.size())
def test_pop_empty_stack(self): test_stack = UniqueStack() self.assertEqual(None, test_stack.pop())
def test_pop_single_item(self): test_stack = UniqueStack() test_stack.push(UniqueLimitedStackTestCase.ITEM_1) self.assertEqual(UniqueLimitedStackTestCase.ITEM_1, test_stack.pop()) self.assertEqual(0, test_stack.size())
def test_push_none(self): test_stack = UniqueStack() with self.assertRaises(TypeError): test_stack.push(None)
def test_peek_size_remains(self): test_stack = UniqueStack() test_stack.push(UniqueLimitedStackTestCase.ITEM_1) self.assertEqual(UniqueLimitedStackTestCase.ITEM_1, test_stack.peek()) self.assertEqual(1, test_stack.size())
def test_push_duplicates(self): test_stack = UniqueStack() test_stack.push(UniqueLimitedStackTestCase.ITEM_1) with self.assertRaises(ValueError): test_stack.push(UniqueLimitedStackTestCase.ITEM_1) self.assertEqual(1, test_stack.size())
def test_push_increases_size(self): test_stack = UniqueStack() test_stack.push(UniqueLimitedStackTestCase.ITEM_1) self.assertEqual(1, test_stack.size())
def test_unique_behavior(self): test_stack = UniqueStack() test_stack.push(STC.ITEM_1) with self.assertRaises(ValueError): test_stack.push(STC.ITEM_1) self.assertEqual(STC.ITEM_1, test_stack.pop())