def test_urandom(self): """urandom() returns random bytes""" for i in xrange(129): self.assertEqual(i, len(util.urandom(i))) # For a large enough sample, each value should appear at least once entropy = util.urandom(65536) values = set(ord(c) for c in entropy) self.assertEqual(256, len(values))