本文整理汇总了Python中Crypto.Random.Fortuna.FortunaAccumulator.which_pools方法的典型用法代码示例。如果您正苦于以下问题:Python FortunaAccumulator.which_pools方法的具体用法?Python FortunaAccumulator.which_pools怎么用?Python FortunaAccumulator.which_pools使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crypto.Random.Fortuna.FortunaAccumulator
的用法示例。
在下文中一共展示了FortunaAccumulator.which_pools方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_which_pools
# 需要导入模块: from Crypto.Random.Fortuna import FortunaAccumulator [as 别名]
# 或者: from Crypto.Random.Fortuna.FortunaAccumulator import which_pools [as 别名]
def test_which_pools(self):
"""FortunaAccumulator.which_pools"""
# which_pools(0) should fail
self.assertRaises(AssertionError, FortunaAccumulator.which_pools, 0)
self.assertEqual(FortunaAccumulator.which_pools(1), [0])
self.assertEqual(FortunaAccumulator.which_pools(2), [0, 1])
self.assertEqual(FortunaAccumulator.which_pools(3), [0])
self.assertEqual(FortunaAccumulator.which_pools(4), [0, 1, 2])
self.assertEqual(FortunaAccumulator.which_pools(5), [0])
self.assertEqual(FortunaAccumulator.which_pools(6), [0, 1])
self.assertEqual(FortunaAccumulator.which_pools(7), [0])
self.assertEqual(FortunaAccumulator.which_pools(8), [0, 1, 2, 3])
for i in range(1, 32):
self.assertEqual(FortunaAccumulator.which_pools(2L**i-1), [0])
self.assertEqual(FortunaAccumulator.which_pools(2L**i), range(i+1))
self.assertEqual(FortunaAccumulator.which_pools(2L**i+1), [0])
self.assertEqual(FortunaAccumulator.which_pools(2L**31), range(32))
self.assertEqual(FortunaAccumulator.which_pools(2L**32), range(32))
self.assertEqual(FortunaAccumulator.which_pools(2L**33), range(32))
self.assertEqual(FortunaAccumulator.which_pools(2L**34), range(32))
self.assertEqual(FortunaAccumulator.which_pools(2L**35), range(32))
self.assertEqual(FortunaAccumulator.which_pools(2L**36), range(32))
self.assertEqual(FortunaAccumulator.which_pools(2L**64), range(32))
self.assertEqual(FortunaAccumulator.which_pools(2L**128), range(32))
示例2: test_which_pools
# 需要导入模块: from Crypto.Random.Fortuna import FortunaAccumulator [as 别名]
# 或者: from Crypto.Random.Fortuna.FortunaAccumulator import which_pools [as 别名]
def test_which_pools(self):
"""FortunaAccumulator.which_pools"""
# which_pools(0) should fail
self.assertRaises(AssertionError, FortunaAccumulator.which_pools, 0)
self.assertEqual(FortunaAccumulator.which_pools(1), [0])
self.assertEqual(FortunaAccumulator.which_pools(2), [0, 1])
self.assertEqual(FortunaAccumulator.which_pools(3), [0])
self.assertEqual(FortunaAccumulator.which_pools(4), [0, 1, 2])
self.assertEqual(FortunaAccumulator.which_pools(5), [0])
self.assertEqual(FortunaAccumulator.which_pools(6), [0, 1])
self.assertEqual(FortunaAccumulator.which_pools(7), [0])
self.assertEqual(FortunaAccumulator.which_pools(8), [0, 1, 2, 3])
for i in range(1, 32):
self.assertEqual(FortunaAccumulator.which_pools(2**i-1), [0])
self.assertEqual(FortunaAccumulator.which_pools(2**i), list(range(i+1)))
self.assertEqual(FortunaAccumulator.which_pools(2**i+1), [0])
self.assertEqual(FortunaAccumulator.which_pools(2**31), list(range(32)))
self.assertEqual(FortunaAccumulator.which_pools(2**32), list(range(32)))
self.assertEqual(FortunaAccumulator.which_pools(2**33), list(range(32)))
self.assertEqual(FortunaAccumulator.which_pools(2**34), list(range(32)))
self.assertEqual(FortunaAccumulator.which_pools(2**35), list(range(32)))
self.assertEqual(FortunaAccumulator.which_pools(2**36), list(range(32)))
self.assertEqual(FortunaAccumulator.which_pools(2**64), list(range(32)))
self.assertEqual(FortunaAccumulator.which_pools(2**128), list(range(32)))