[Python-checkins] cpython (2.7): Issue #23458: Skip test_urandom_fd_non_inheritable on OS X 10.4 since

ned.deily python-checkins at python.org
Tue Mar 17 23:18:52 CET 2015


https://hg.python.org/cpython/rev/730bbd1499ba
changeset:   95024:730bbd1499ba
branch:      2.7
parent:      95019:cceeb6b10f12
user:        Ned Deily <nad at acm.org>
date:        Tue Mar 17 15:18:07 2015 -0700
summary:
  Issue #23458: Skip test_urandom_fd_non_inheritable on OS X 10.4 since
FD_CLOEXEC is not supported there.

files:
  Lib/test/test_os.py      |   2 +
  Lib/test/test_support.py |  30 +++++++++++++++++++++++++++-
  2 files changed, 31 insertions(+), 1 deletions(-)


diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -571,6 +571,8 @@
 
     # 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
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -28,7 +28,8 @@
 __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 @@
             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).

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list