[Python-3000-checkins] r63798 - in python/branches/py3k: Lib/platform.py Lib/test/test_platform.py
benjamin.peterson
python-3000-checkins at python.org
Thu May 29 23:22:40 CEST 2008
Author: benjamin.peterson
Date: Thu May 29 23:22:40 2008
New Revision: 63798
Log:
Merged revisions 63460,63464 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r63460 | ronald.oussoren | 2008-05-18 15:54:47 -0500 (Sun, 18 May 2008) | 6 lines
- 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.
........
r63464 | benjamin.peterson | 2008-05-18 17:07:42 -0500 (Sun, 18 May 2008) | 2 lines
fix test_platform (os was not imported)
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/platform.py
python/branches/py3k/Lib/test/test_platform.py
Modified: python/branches/py3k/Lib/platform.py
==============================================================================
--- python/branches/py3k/Lib/platform.py (original)
+++ python/branches/py3k/Lib/platform.py Thu May 29 23:22:40 2008
@@ -729,7 +729,11 @@
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 @@
0x60:'beta',
0x80:'final'}.get(stage,'')
versioninfo = (version,stage,nonrel)
+
+
if sysa:
machine = {0x1: '68k',
0x2: 'PowerPC',
Modified: python/branches/py3k/Lib/test/test_platform.py
==============================================================================
--- python/branches/py3k/Lib/test/test_platform.py (original)
+++ python/branches/py3k/Lib/test/test_platform.py Thu May 29 23:22:40 2008
@@ -1,4 +1,5 @@
import sys
+import os
import unittest
import platform
@@ -63,12 +64,29 @@
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()
More information about the Python-3000-checkins
mailing list