本文整理汇总了Python中priorityQueue.PriorityQueue.cleanChances方法的典型用法代码示例。如果您正苦于以下问题:Python PriorityQueue.cleanChances方法的具体用法?Python PriorityQueue.cleanChances怎么用?Python PriorityQueue.cleanChances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类priorityQueue.PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue.cleanChances方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PriorityQueueTest
# 需要导入模块: from priorityQueue import PriorityQueue [as 别名]
# 或者: from priorityQueue.PriorityQueue import cleanChances [as 别名]
class PriorityQueueTest(unittest.TestCase):
def setUp(self):
self.priority = PriorityQueue(3,5)
self.aPcb1 = Mock()
when(self.aPcb1).getPriority().thenReturn(2)
self.aPcb2 = Mock()
when(self.aPcb2).getPriority().thenReturn(2)
def test_addPcb_initialAdd(self):
self.priority.addPcb(self.aPcb1)
chance = self.priority.table.get(6)
assert (chance.elementos[0] == self.aPcb1)
def test_addPcb_withPcb(self):
self.priority.addPcb(self.aPcb1)
self.priority.addPcb(self.aPcb2)
chance = self.priority.table.get(6)
assert (chance.elementos[0] == self.aPcb2)
assert (chance.elementos[1] == self.aPcb1)
def test_getMax(self):
self.priority.addPcb(self.aPcb1)
self.priority.addPcb(self.aPcb2)
aPcb3 = Mock()
when(aPcb3).getPriority().thenReturn(4)
self.priority.addPcb(aPcb3)
assert (self.priority.getMax() == aPcb3)
assert (self.priority.getMax() == self.aPcb1)
def test_cleanChances(self):
chan1 = Chance()
chan2 = Chance()
chan3 = Chance()
aPcb = Mock()
chan2.elementos = [aPcb]
self.priority.table = {1:chan1,2:chan2,3:chan3}
assert(self.priority.table[1] == chan1)
assert(self.priority.table[2] == chan2)
assert(self.priority.table[3] == chan3)
assert(len(self.priority.table) == 3)
self.priority.cleanChances()
assert(len(self.priority.table) == 1)
assert(self.priority.table[2] == chan2)