本文整理汇总了Python中pitz.project.Project.order方法的典型用法代码示例。如果您正苦于以下问题:Python Project.order方法的具体用法?Python Project.order怎么用?Python Project.order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pitz.project.Project
的用法示例。
在下文中一共展示了Project.order方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestSorting1
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import order [as 别名]
class TestSorting1(unittest.TestCase):
"""
Verify that we can sort on the pscore attribute.
"""
def setUp(self):
self.p = Project(title="test pscore")
self.e1 = Entity(self.p, title="e1")
self.e2 = Entity(self.p, title="e2")
self.e3 = Entity(self.p, title="e3")
self.e4 = Entity(self.p, title="e4")
print("Original order of entities:")
for e in self.p:
print("%(title)s %(pscore)s" % e)
def test_sort(self):
assert self.p.length == 4
assert self.p.order_method == \
pitz.by_milestone_status_pscore_created_time, \
self.p.order_method
for e in self.p:
assert e['pscore'] == 0, e['pscore']
assert list(self.p) == [self.e1, self.e2, self.e3, self.e4]
self.e1['pscore'] = -10
self.p.order()
print("After first pscore change")
for e in self.p:
print("%(title)s %(pscore)s" % e)
assert list(self.p) == [self.e2, self.e3, self.e4, self.e1]
self.e3['pscore'] = 10
self.p.order()
print("After second pscore change")
for e in self.p:
print "%(title)s %(pscore)s" % e
assert list(self.p) == [self.e3, self.e2, self.e4, self.e1], \
"self.p is \n---\n%s\n---\n" % self.p
示例2: TestByPscoreAndMilestone
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import order [as 别名]
class TestByPscoreAndMilestone(unittest.TestCase):
def setUp(self):
self.p = Project(title="test sorting...")
Entity(self.p, title="a", pscore=2)
Entity(self.p, title="b", pscore=1)
Entity(self.p, title="c", pscore=3)
def test_by_pscore_and_milestone(self):
self.p.order(by_pscore_and_milestone)
prevscore = 99
for e in self.p:
print(e)
assert e["pscore"] < prevscore, "%s, %s" % (e["pscore"], prevscore)
prevscore = e["pscore"]