class TestMin(unittest.TestCase): def setUp(self): self.q = Queue() def test_constructor(self): self.assertEqual(type(self.q), Queue) def test_fifo_append_all_then_pop(self): for i in range(10): self.q.append(i) for i in range(10): with self.subTest(i=i): self.assertEqual(self.q.popleft(), i) def test_fifo_concerrent_append_and_pop(self): for i in range(10): with self.subTest(i=i): self.q.append(i) self.assertEqual(self.q.popleft(), i)
class TestPopleftMethod(unittest.TestCase): def setUp(self): self.q = Queue() def test_pop_from_empty(self): with self.assertRaises(IndexError): self.q.popleft() self.assertEqual(self.q.head, None) def test_pop_with_1_elem(self): self.q.append(0) self.assertEqual(self.q.popleft(), 0) self.assertEqual(self.q.head, None) def test_pop_with_multiple_elem(self): for i in range(10): self.q.append(i) for i in range(10): with self.subTest(i=i): self.assertEqual(self.q.popleft(), i) self.assertEqual(self.q.head, None)