Kaydet (Commit) 173a1f3d authored tarafından Victor Stinner's avatar Victor Stinner

Fix test_os.GetRandomTests()

Issue #27778: Skip getrandom() tests if getrandom() fails with ENOSYS.
üst 6cebd484
......@@ -1271,6 +1271,18 @@ class URandomTests(unittest.TestCase):
@unittest.skipUnless(hasattr(os, 'getrandom'), 'need os.getrandom()')
class GetRandomTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
try:
os.getrandom(1)
except OSError as exc:
if exc.errno == errno.ENOSYS:
# Python compiled on a more recent Linux version
# than the current Linux kernel
raise unittest.SkipTest("getrandom() syscall fails with ENOSYS")
else:
raise
def test_getrandom_type(self):
data = os.getrandom(16)
self.assertIsInstance(data, bytes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment