summaryrefslogtreecommitdiffstats
path: root/Lib/test/support.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-06-01 11:19:07 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-06-01 11:19:07 (GMT)
commitebbbdafd8782b02eaf05f5c99ed000dbd6ad0ae1 (patch)
tree1410655038edec7924f0b23bcd9fdc15aed0c01f /Lib/test/support.py
parentfce9233e93cb217a31d8c5b1776b4ec226595dc1 (diff)
parent88701e27e90c0b70e2b22b06ad8bbfa231cf99dc (diff)
downloadcpython-ebbbdafd8782b02eaf05f5c99ed000dbd6ad0ae1.zip
cpython-ebbbdafd8782b02eaf05f5c99ed000dbd6ad0ae1.tar.gz
cpython-ebbbdafd8782b02eaf05f5c99ed000dbd6ad0ae1.tar.bz2
(Merge 3.2) Close #12230: Mac OS X Tiger (10.4) has a kernel bug: sometimes,
the file descriptor of a pipe closed in the parent process is valid in the child process according to fstat(), but the mode of the file descriptor is invalid, and read or write raise an error. test.support.requires_mac_ver() is now a decorator, as suggested by Ezio Melotti, and its docstring is fixed (linux_version => mac_ver).
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r--Lib/test/support.py39
1 files changed, 24 insertions, 15 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py
index 1bf9ca5..d3f7f4c 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -301,23 +301,32 @@ def linux_version():
return 0, 0, 0
def requires_mac_ver(*min_version):
- """Raise SkipTest if the OS is Mac OS X and the OS X version if less than
- min_version.
+ """Decorator raising SkipTest if the OS is Mac OS X and the OS X
+ version if less than min_version.
- For example, support.requires_linux_version(10, 5) raises SkipTest if the
- version is less than 10.5.
+ For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
+ is lesser than 10.5.
"""
- if sys.platform != 'darwin':
- return
- version_txt = platform.mac_ver()[0]
- try:
- version = tuple(map(int, version_txt.split('.')))
- except ValueError:
- return
- 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))
+ 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
+
HOST = 'localhost'