[Python-checkins] r63460 - in python/trunk/Lib: platform.py test/test_platform.py

Brett Cannon brett at python.org
Thu May 22 00:01:52 CEST 2008


On Sun, May 18, 2008 at 1:54 PM, ronald.oussoren
<python-checkins at python.org> wrote:
> Author: ronald.oussoren
> Date: Sun May 18 22:54:47 2008
> New Revision: 63460
>
> Log:
> - 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 is failing on the trunk because it assumes you built with
``--enable-toolbox-glue`` and thus have gestalt available. While in
3.0 since gestalt will be the only Mac-specific module it will be
reasonable to just always build the module on Macs (once gestalt is in
3.0 this should be made sure), you can't assume that with the trunk.


>
> Modified:
>   python/trunk/Lib/platform.py
>   python/trunk/Lib/test/test_platform.py
>
> Modified: python/trunk/Lib/platform.py
> ==============================================================================
> --- python/trunk/Lib/platform.py        (original)
> +++ python/trunk/Lib/platform.py        Sun May 18 22:54:47 2008
> @@ -733,7 +733,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 & 0xFF000000L) >> 24)
>         minor =  (sysu & 0x00F00000) >> 20
>         bugfix = (sysu & 0x000F0000) >> 16
> @@ -746,6 +750,8 @@
>                  0x60:'beta',
>                  0x80:'final'}.get(stage,'')
>         versioninfo = (version,stage,nonrel)
> +
> +
>     if sysa:
>         machine = {0x1: '68k',
>                    0x2: 'PowerPC',
>
> Modified: python/trunk/Lib/test/test_platform.py
> ==============================================================================
> --- python/trunk/Lib/test/test_platform.py      (original)
> +++ python/trunk/Lib/test/test_platform.py      Sun May 18 22:54:47 2008
> @@ -63,12 +63,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()
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>


More information about the Python-checkins mailing list