diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-01 10:28:04 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-01 10:28:04 (GMT) |
commit | fce9233e93cb217a31d8c5b1776b4ec226595dc1 (patch) | |
tree | e3e94957b30d2f544cb9847c36601968f7bc9edd /Lib/test/support.py | |
parent | 197a59f49b1b3e99e04144b25b4bf8bf233e69df (diff) | |
download | cpython-fce9233e93cb217a31d8c5b1776b4ec226595dc1.zip cpython-fce9233e93cb217a31d8c5b1776b4ec226595dc1.tar.gz cpython-fce9233e93cb217a31d8c5b1776b4ec226595dc1.tar.bz2 |
test.support: add requires_mac_ver() function
Add also linux_version() to __all__.
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r-- | Lib/test/support.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py index 6724e9b..1bf9ca5 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -37,7 +37,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", "linux_version", "requires_mac_ver", + "find_unused_port", "bind_port", "IPV6_ENABLED", "is_jython", "TESTFN", "HOST", "SAVEDCWD", "temp_cwd", "findfile", "sortdict", "check_syntax_error", "open_urlresource", "check_warnings", "CleanImport", "EnvironmentVarGuard", "TransientResource", @@ -299,6 +300,25 @@ def linux_version(): except ValueError: 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. + + For example, support.requires_linux_version(10, 5) raises SkipTest if the + version is less 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)) + HOST = 'localhost' def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM): |