summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-09-07 02:57:40 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-09-07 02:57:40 (GMT)
commit173a1f3dc7a8b43b49e3ef483714c1d51b60d868 (patch)
tree1074ffe386d11407d4abeed25e7ca29c389268c2 /Lib/test/test_os.py
parent6cebd48425ad9a3b325d9907c9a37cae04a788b9 (diff)
downloadcpython-173a1f3dc7a8b43b49e3ef483714c1d51b60d868.zip
cpython-173a1f3dc7a8b43b49e3ef483714c1d51b60d868.tar.gz
cpython-173a1f3dc7a8b43b49e3ef483714c1d51b60d868.tar.bz2
Fix test_os.GetRandomTests()
Issue #27778: Skip getrandom() tests if getrandom() fails with ENOSYS.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 5205672..2de94c6 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -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)