def test_remove_rear(self): d = Dequeue() d.add_front("apple") d.add_front("banana") d.add_front("cherry") self.assertEqual(d.remove_rear(), "apple") self.assertEqual(d.items, ["cherry", "banana"])
def test_add_front(self): """Test add front method.""" d = Dequeue() self.assertTrue(d._items == []) d.add_front(1) d.add_front(2) self.assertEqual(d._items, [2, 1])
def test_size(self): d = Dequeue() self.assertEqual(d.size(), 0) d.add_front("apple") self.assertEqual(d.size(), 1) d.add_front("banana") self.assertEqual(d.size(), 2) d.add_front("cherry") self.assertEqual(d.size(), 3)
def test_is_empty(self): """Test is empty method.""" d = Dequeue() self.assertTrue(d.is_empty()) d.add_front(1) self.assertFalse(d.is_empty())
def create_dequeue(self, string): dequeue= Dequeue() for char in string: if not char.isspace() and char.isalnum(): dequeue.add_front(char) return dequeue
def test_is_empty(self): d = Dequeue() self.assertEqual(d.is_empty(), True) d.add_front("apple") self.assertEqual(d.is_empty(), False)
def test_add_front(self): d = Dequeue() self.assertEqual(d.items, []) d.add_front("apple") d.add_front("banana") self.assertEqual(d.items, ["banana", "apple"])