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 94cb7a2429
commit fe02e39029
6 changed files with 56 additions and 9 deletions

View file

@ -27,6 +27,7 @@ import codecs
import decimal
import fractions
import pickle
import sysconfig
try:
import threading
except ImportError:
@ -1053,6 +1054,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.