diff options
Diffstat (limited to 'Lib/test/test_platform.py')
-rw-r--r-- | Lib/test/test_platform.py | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 941d428c19e..8751aa86ba8 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -4,26 +4,32 @@ import unittest import platform import subprocess -from test import test_support +from test import 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) + @support.skip_unless_symlink + def test_architecture_via_symlink(self): # issue3762 + # On Windows, the EXE needs to know where pythonXY.dll is at so we have + # to add the directory to the path. + if sys.platform == "win32": + os.environ["Path"] = "{};{}".format( + os.path.dirname(sys.executable), os.environ["Path"]) + + 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(support.TESTFN) + os.symlink(real, link) + try: + self.assertEqual(get(real), get(link)) + finally: + os.remove(link) def test_platform(self): for aliased in (False, True): @@ -51,11 +57,13 @@ class PlatformTest(unittest.TestCase): def setUp(self): self.save_version = sys.version self.save_subversion = sys.subversion + self.save_mercurial = sys._mercurial self.save_platform = sys.platform def tearDown(self): sys.version = self.save_version sys.subversion = self.save_subversion + sys._mercurial = self.save_mercurial sys.platform = self.save_platform def test_sys_version(self): @@ -100,13 +108,15 @@ class PlatformTest(unittest.TestCase): "") } for (version_tag, subversion, sys_platform), info in \ - sys_versions.iteritems(): + sys_versions.items(): sys.version = version_tag if subversion is None: + if hasattr(sys, "_mercurial"): + del sys._mercurial if hasattr(sys, "subversion"): del sys.subversion else: - sys.subversion = subversion + sys._mercurial = subversion if sys_platform is not None: sys.platform = sys_platform self.assertEqual(platform.python_implementation(), info[0]) @@ -134,7 +144,7 @@ class PlatformTest(unittest.TestCase): # using it, per # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx try: - with test_support.EnvironmentVarGuard() as environ: + with support.EnvironmentVarGuard() as environ: if 'PROCESSOR_ARCHITEW6432' in environ: del environ['PROCESSOR_ARCHITEW6432'] environ['PROCESSOR_ARCHITECTURE'] = 'foo' @@ -159,14 +169,7 @@ class PlatformTest(unittest.TestCase): 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': + if platform.uname()[0] == 'Darwin': # We're on a MacOSX system, check that # the right version information is returned fd = os.popen('sw_vers', 'r') @@ -246,7 +249,7 @@ class PlatformTest(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( PlatformTest ) |