]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #23458: Skip test_urandom_fd_non_inheritable on OS X 10.4 since
authorNed Deily <nad@acm.org>
Tue, 17 Mar 2015 22:18:07 +0000 (15:18 -0700)
committerNed Deily <nad@acm.org>
Tue, 17 Mar 2015 22:18:07 +0000 (15:18 -0700)
FD_CLOEXEC is not supported there.

Lib/test/test_os.py
Lib/test/test_support.py

index ee6027b120242b42761c1675164b847970460933..d82ee58f1b44a389d2b82768f7acde02c4f62d1c 100644 (file)
@@ -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
index 7b831909cfc72f033df933af6acc43a0c1ab70ab..1fbd5b444ba4fe4e649a78a4fe8a4b151777add2 100644 (file)
@@ -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).