Пример #1
0
 def testSizeOfQ(self):
     q = qu.Queue()
     w1 = wd.Word(address=22)
     w2 = wd.Word(address=3)
     q.enqueue(word=w1)
     q.enqueue(word=w2)
     self.assertEqual(q.size(), 2, 'Size does not work properly')
Пример #2
0
 def testEnqueueIntoNonEmptyQ(self):
     q = qu.Queue()
     w1 = wd.Word(address=22)
     w2 = wd.Word(address=3)
     q.enqueue(word=w1)
     q.enqueue(word=w2)
     self.assertEqual(q.size(), 2, 'Enqueue does not work properly')
Пример #3
0
 def testDequeueFromNonEmptyQReturnValue(self):
     q = qu.Queue()
     w1 = wd.Word(address=22)
     w2 = wd.Word(address=3)
     q.enqueue(word=w1)
     q.enqueue(word=w2)
     self.assertEqual(q.dequeue().getTerminalAddress(), 22,
                      'Dequeue does not work properly')
Пример #4
0
 def testDequeueFromNonEmptyQQueueStatus(self):
     q = qu.Queue()
     w1 = wd.Word(address=22)
     w2 = wd.Word(address=3)
     q.enqueue(word=w1)
     q.enqueue(word=w2)
     q.dequeue()
     self.assertEqual(q.queue.count(w1), 0,
                      'Dequeue does not work properly')
Пример #5
0
 def testDequeueFromEmptyQErrorMessage(self):
     q = qu.Queue()
     self.assertRaisesRegexp(Exception, "^Queue.dequeue:\s\s", q.dequeue)
Пример #6
0
 def testDequeueFromEmptyQErrorType(self):
     q = qu.Queue()
     self.assertRaises(ValueError, q.dequeue)
Пример #7
0
 def testEnqueueIntoEmptyQ(self):
     q = qu.Queue()
     w = wd.Word(address=22)
     q.enqueue(word=w)
     self.assertEqual(q.size(), 1, 'Enqueue does not work properly')
Пример #8
0
 def testEmptyQIsEmpty(self):
     q = qu.Queue()
     self.assertEqual(q.isEmpty(), True, 'isEmpty does not work properly')
Пример #9
0
 def testNonEmptyQIsEmpty(self):
     q = qu.Queue()
     w = wd.Word(address=22)
     q.enqueue(word=w)
     self.assertEqual(q.isEmpty(), False, 'isEmpty does not work properly')
Пример #10
0
 def testQInstantiation(self):
     q = qu.Queue()
     assert isinstance(q, qu.Queue), 'queue is not an instance of Queue'
Пример #11
0
 def testSizeExists(self):
     q = qu.Queue()
     assert "size" in dir(q), 'Method by name size does not exists'
Пример #12
0
 def testDequeueExists(self):
     q = qu.Queue()
     assert "dequeue" in dir(q), 'Method by name dequeue does not exists'
Пример #13
0
 def testIsEmptyExists(self):
     q = qu.Queue()
     assert "isEmpty" in dir(q), 'Method by name isEmpty does not exists'
Пример #14
0
 def testInitExists(self):
     q = qu.Queue()
     assert "__init__" in dir(q), 'Method by name __init__ does not exists'