Example #1
0
	def test_is_empty(self):
		s = Stack()
		self.assertEqual(s.is_empty(), True)

		s.push(2)
		self.assertEqual(s.is_empty(), False)

		s.pop()
		self.assertEqual(s.is_empty(), True)
Example #2
0
 def test_Stack(self):
     self.assertIn('__init__', dir(Stack))
     self.assertIn('pop', dir(Stack))
     self.assertIn('is_empty', dir(Stack))
     testins = Stack()
     testins.push("first")
     testins.push(2)
     testins.push(3)
     self.assertEqual(testins.data, [3, 2, "first"])
     testins.pop()
     self.assertEqual(testins.data, [2, "first"])
     self.assertEqual(testins.peek(), 2)
     self.assertEqual(testins.size(), 2)
     self.assertEqual(testins.is_empty(), False)
     testins.pop()
     testins.pop()
     self.assertEqual(testins.is_empty(), True)
     self.assertRaises(EmptyStack, testins.pop)
     self.assertRaises(EmptyStack, testins.peek)
Example #3
0
	def test_pop_empty(self):
		s = Stack()
		self.assertRaises(EmptyStack, s.pop)
Example #4
0
	def test_peek(self):
		s = Stack()
		s.push(2)
		s.push(4)
		self.assertEqual(s.peek(), 4)
Example #5
0
	def test_pop(self):
		s = Stack()
		s.push(2)
		self.assertEqual(s.pop(), 2)
Example #6
0
	def test_size(self):
		s = Stack()

		s.push(2)
		self.assertEqual(s.size(), 1)
Example #7
0
 def setUp(self):
     self.stack = Stack()