- Add unittests for platform.mac_ver (or rather, ensure that the unittest for
that function actually tests something on OSX). - Add documentation to platform.mac_ver that explains why the middle element of the return value will not contain useful information.
This commit is contained in:
parent
f5c38dadf6
commit
7a0f4c75b1
|
@ -733,7 +733,11 @@ def mac_ver(release='',versioninfo=('','',''),machine=''):
|
||||||
release = '%i.%i.%i' %(major, minor, patch)
|
release = '%i.%i.%i' %(major, minor, patch)
|
||||||
else:
|
else:
|
||||||
release = '%s.%i.%i' % (_bcd2str(major),minor,patch)
|
release = '%s.%i.%i' % (_bcd2str(major),minor,patch)
|
||||||
|
|
||||||
if sysu:
|
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 & 0xFF000000L) >> 24)
|
major = int((sysu & 0xFF000000L) >> 24)
|
||||||
minor = (sysu & 0x00F00000) >> 20
|
minor = (sysu & 0x00F00000) >> 20
|
||||||
bugfix = (sysu & 0x000F0000) >> 16
|
bugfix = (sysu & 0x000F0000) >> 16
|
||||||
|
@ -746,6 +750,8 @@ def mac_ver(release='',versioninfo=('','',''),machine=''):
|
||||||
0x60:'beta',
|
0x60:'beta',
|
||||||
0x80:'final'}.get(stage,'')
|
0x80:'final'}.get(stage,'')
|
||||||
versioninfo = (version,stage,nonrel)
|
versioninfo = (version,stage,nonrel)
|
||||||
|
|
||||||
|
|
||||||
if sysa:
|
if sysa:
|
||||||
machine = {0x1: '68k',
|
machine = {0x1: '68k',
|
||||||
0x2: 'PowerPC',
|
0x2: 'PowerPC',
|
||||||
|
|
|
@ -63,12 +63,29 @@ class PlatformTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_mac_ver(self):
|
def test_mac_ver(self):
|
||||||
res = platform.mac_ver()
|
res = platform.mac_ver()
|
||||||
try:
|
|
||||||
import gestalt
|
if os.uname()[0] == 'Darwin':
|
||||||
except ImportError: pass
|
# We're on a MacOSX system, check that
|
||||||
else:
|
# the right version information is returned
|
||||||
if sys.platform == 'darwin':
|
fd = os.popen('sw_vers', 'r')
|
||||||
self.assert_(all(res))
|
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):
|
def test_dist(self):
|
||||||
res = platform.dist()
|
res = platform.dist()
|
||||||
|
|
Loading…
Reference in New Issue