Commit 99bd57d7 authored by Ned Deily's avatar Ned Deily

Issue #23458: Skip test_urandom_fd_non_inheritable on OS X 10.4 since

FD_CLOEXEC is not supported there.
parent b0a53fca
......@@ -571,6 +571,8 @@ class URandomTests (unittest.TestCase):
# os.urandom() doesn't use a file descriptor on Windows
@unittest.skipIf(sys.platform == "win32", "POSIX specific tests")
# FD_CLOEXEC is first supported on OS X 10.5
@test_support.requires_mac_ver(10, 5)
def test_urandom_fd_non_inheritable(self):
# Issue #23458: os.urandom() keeps a file descriptor open, but it
# must be non inheritable
......
......@@ -28,7 +28,8 @@ except ImportError:
__all__ = ["Error", "TestFailed", "ResourceDenied", "import_module",
"verbose", "use_resources", "max_memuse", "record_original_stdout",
"get_original_stdout", "unload", "unlink", "rmtree", "forget",
"is_resource_enabled", "requires", "find_unused_port", "bind_port",
"is_resource_enabled", "requires", "requires_mac_ver",
"find_unused_port", "bind_port",
"fcmp", "have_unicode", "is_jython", "TESTFN", "HOST", "FUZZ",
"SAVEDCWD", "temp_cwd", "findfile", "sortdict", "check_syntax_error",
"open_urlresource", "check_warnings", "check_py3k_warnings",
......@@ -361,6 +362,33 @@ def requires(resource, msg=None):
msg = "Use of the `%s' resource not enabled" % resource
raise ResourceDenied(msg)
def requires_mac_ver(*min_version):
"""Decorator raising SkipTest if the OS is Mac OS X and the OS X
version if less than min_version.
For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
is lesser than 10.5.
"""
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
if sys.platform == 'darwin':
version_txt = platform.mac_ver()[0]
try:
version = tuple(map(int, version_txt.split('.')))
except ValueError:
pass
else:
if version < min_version:
min_version_txt = '.'.join(map(str, min_version))
raise unittest.SkipTest(
"Mac OS X %s or higher required, not %s"
% (min_version_txt, version_txt))
return func(*args, **kw)
wrapper.min_version = min_version
return wrapper
return decorator
# Don't use "localhost", since resolving it uses the DNS under recent
# Windows versions (see issue #18792).
......
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