Beispiel #1
0
 def test_get_put_nowait(self):
     q = queues.Queue(maxsize=1)
     q.put_nowait(12)
     try:
         q.put_nowait(42)
         self.assertTrue(False)
     except Exception as e:
         self.assertEqual(type(e), queues.QueueFull)
     self.assertEqual(q.get_nowait(), 12)
     try:
         q.get_nowait()
         self.assertTrue(False)
     except Exception as e:
         self.assertEqual(type(e), queues.QueueEmpty)
Beispiel #2
0
 def test_full(self):
     q = queues.Queue(maxsize=1)
     self.assertFalse(q.full())
     q.put_nowait(10)
     self.assertTrue(q.full())
Beispiel #3
0
 def test_empty(self):
     q = queues.Queue()
     self.assertTrue(q.empty())
     q.put_nowait(10)
     self.assertFalse(q.empty())
Beispiel #4
0
 def test_qsize(self):
     q = queues.Queue()
     for n in range(10):
         q.put_nowait(10)
     self.assertEqual(q.qsize(), 10)
Beispiel #5
0
 def test_get_put(self):
     q = queues.Queue(maxsize=1)
     self._val(q.put(42))
     self.assertEqual(self._val(q.get()), 42)