Issue #22585: On OpenBSD 5.6 and newer, os.urandom() now calls getentropy(),

instead of reading /dev/urandom, to get pseudo-random bytes.
This commit is contained in:
Victor Stinner 2014-12-21 01:16:38 +01:00
parent 3c6fe4da88
commit 4d6a3d6c01
6 changed files with 50 additions and 6 deletions

View file

@ -27,6 +27,7 @@ import codecs
import decimal
import fractions
import pickle
import sysconfig
try:
import threading
except ImportError:
@ -1103,6 +1104,12 @@ class URandomTests(unittest.TestCase):
data2 = self.get_urandom_subprocess(16)
self.assertNotEqual(data1, data2)
HAVE_GETENTROPY = (sysconfig.get_config_var('HAVE_GETENTROPY') == 1)
@unittest.skipIf(HAVE_GETENTROPY,
"getentropy() does not use a file descriptor")
class URandomFDTests(unittest.TestCase):
@unittest.skipUnless(resource, "test requires the resource module")
def test_urandom_failure(self):
# Check urandom() failing when it is not able to open /dev/random.