diff options
-rwxr-xr-x | Lib/platform.py | 6 | ||||
-rw-r--r-- | Lib/test/test_platform.py | 30 |
2 files changed, 30 insertions, 6 deletions
diff --git a/Lib/platform.py b/Lib/platform.py index 2a69fd6..8447d41 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -729,7 +729,11 @@ def mac_ver(release='',versioninfo=('','',''),machine=''): release = '%i.%i.%i' %(major, minor, patch) else: release = '%s.%i.%i' % (_bcd2str(major),minor,patch) + if sysu: + # NOTE: this block is left as documentation of the + # intention of this function, the 'sysu' gestalt is no + # longer available and there are no alternatives. major = int((sysu & 0xFF000000) >> 24) minor = (sysu & 0x00F00000) >> 20 bugfix = (sysu & 0x000F0000) >> 16 @@ -742,6 +746,8 @@ def mac_ver(release='',versioninfo=('','',''),machine=''): 0x60:'beta', 0x80:'final'}.get(stage,'') versioninfo = (version,stage,nonrel) + + if sysa: machine = {0x1: '68k', 0x2: 'PowerPC', diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 3758060..bc02d1e 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -1,4 +1,5 @@ import sys +import os import unittest import platform @@ -63,12 +64,29 @@ class PlatformTest(unittest.TestCase): def test_mac_ver(self): res = platform.mac_ver() - try: - import gestalt - except ImportError: pass - else: - if sys.platform == 'darwin': - self.assert_(all(res)) + + if os.uname()[0] == 'Darwin': + # We're on a MacOSX system, check that + # the right version information is returned + fd = os.popen('sw_vers', 'r') + real_ver = None + for ln in fd: + if ln.startswith('ProductVersion:'): + real_ver = ln.strip().split()[-1] + break + fd.close() + self.failIf(real_ver is None) + self.assertEquals(res[0], real_ver) + + # res[1] claims to contain + # (version, dev_stage, non_release_version) + # That information is no longer available + self.assertEquals(res[1], ('', '', '')) + + if sys.byteorder == 'little': + self.assertEquals(res[2], 'i386') + else: + self.assertEquals(res[2], 'PowerPC') def test_dist(self): res = platform.dist() |