mirror of
https://github.com/python/cpython.git
synced 2025-08-11 12:29:34 +00:00

svn+ssh://pythondev@svn.python.org/python/trunk ........ r66809 | hirokazu.yamamoto | 2008-10-06 10:57:03 +0900 | 1 line Added the test for issue3762. ........ r66810 | hirokazu.yamamoto | 2008-10-06 11:41:59 +0900 | 1 line More strict test. Consider the case sys.executable itself is symlink. ........ r66835 | hirokazu.yamamoto | 2008-10-08 03:10:47 +0900 | 1 line more intensive test on dbm. ........ r66862 | hirokazu.yamamoto | 2008-10-09 19:00:30 +0900 | 3 lines On windows, os.chdir given unicode was not working if GetCurrentDirectoryW returned a path longer than MAX_PATH. (But It's doubtful this code path is really executed because I cannot move to such directory on win2k) ........ r66863 | hirokazu.yamamoto | 2008-10-09 19:11:21 +0900 | 1 line r66862 contained memory leak. ........
131 lines
3.6 KiB
Python
131 lines
3.6 KiB
Python
import sys
|
|
import os
|
|
import unittest
|
|
import platform
|
|
import subprocess
|
|
|
|
from test import test_support
|
|
|
|
class PlatformTest(unittest.TestCase):
|
|
def test_architecture(self):
|
|
res = platform.architecture()
|
|
|
|
if hasattr(os, "symlink"):
|
|
def test_architecture_via_symlink(self): # issue3762
|
|
def get(python):
|
|
cmd = [python, '-c',
|
|
'import platform; print platform.architecture()']
|
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
|
return p.communicate()
|
|
real = os.path.realpath(sys.executable)
|
|
link = os.path.abspath(test_support.TESTFN)
|
|
os.symlink(real, link)
|
|
try:
|
|
self.assertEqual(get(real), get(link))
|
|
finally:
|
|
os.remove(link)
|
|
|
|
def test_machine(self):
|
|
res = platform.machine()
|
|
|
|
def test_node(self):
|
|
res = platform.node()
|
|
|
|
def test_platform(self):
|
|
for aliased in (False, True):
|
|
for terse in (False, True):
|
|
res = platform.platform(aliased, terse)
|
|
|
|
def test_processor(self):
|
|
res = platform.processor()
|
|
|
|
def test_python_build(self):
|
|
res = platform.python_build()
|
|
|
|
def test_python_compiler(self):
|
|
res = platform.python_compiler()
|
|
|
|
def test_version(self):
|
|
res1 = platform.version()
|
|
res2 = platform.version_tuple()
|
|
self.assertEqual(res1, ".".join(res2))
|
|
|
|
def test_release(self):
|
|
res = platform.release()
|
|
|
|
def test_system(self):
|
|
res = platform.system()
|
|
|
|
def test_version(self):
|
|
res = platform.version()
|
|
|
|
def test_system_alias(self):
|
|
res = platform.system_alias(
|
|
platform.system(),
|
|
platform.release(),
|
|
platform.version(),
|
|
)
|
|
|
|
def test_uname(self):
|
|
res = platform.uname()
|
|
self.assert_(any(res))
|
|
|
|
def test_java_ver(self):
|
|
res = platform.java_ver()
|
|
if sys.platform == 'java':
|
|
self.assert_(all(res))
|
|
|
|
def test_win32_ver(self):
|
|
res = platform.win32_ver()
|
|
|
|
def test_mac_ver(self):
|
|
res = platform.mac_ver()
|
|
|
|
try:
|
|
import gestalt
|
|
except ImportError:
|
|
have_toolbox_glue = False
|
|
else:
|
|
have_toolbox_glue = True
|
|
|
|
if have_toolbox_glue and platform.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()
|
|
|
|
def test_libc_ver(self):
|
|
import os
|
|
if os.path.isdir(sys.executable) and \
|
|
os.path.exists(sys.executable+'.exe'):
|
|
# Cygwin horror
|
|
executable = executable + '.exe'
|
|
res = platform.libc_ver(sys.executable)
|
|
|
|
def test_main():
|
|
test_support.run_unittest(
|
|
PlatformTest
|
|
)
|
|
|
|
if __name__ == '__main__':
|
|
test_main()
|