changeset: 103202:7a243a40b421 user: Victor Stinner date: Tue Sep 06 19:57:40 2016 -0700 files: Lib/test/test_os.py description: Fix test_os.GetRandomTests() Issue #27778: Skip getrandom() tests if getrandom() fails with ENOSYS. diff -r 786c34bdc27a -r 7a243a40b421 Lib/test/test_os.py --- a/Lib/test/test_os.py Tue Sep 06 19:55:55 2016 -0700 +++ b/Lib/test/test_os.py Tue Sep 06 19:57:40 2016 -0700 @@ -1271,6 +1271,18 @@ @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)