def test_size(): test = Queue() test.enqueue(3) assert (test.size() == 1) test.enqueue(34) assert (test.size() == 2) test.dequeue() assert (test.size() == 1)
def hotpotato(namelist, number): namequeue = Queue() for name in namelist: namequeue.enqueue(name) while int(namequeue.size()) > 1: for i in range(number): namequeue.enqueue(namequeue.dequeue()) namequeue.dequeue() return namequeue.dequeue()
class QueueTest(unittest.TestCase): def setUp(self): self.q = Queue() def tearDown(self): while not self.q.isEmpty(): self.q.dequeue() def test_enqueue(self): value = 'A' self.q.enqueue(value) self.assertEqual(1, self.q.size())