summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2010-03-05 00:16:02 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2010-03-05 00:16:02 (GMT)
commitdd7bef9bf56933851e68094ffc70f8f20bc6b036 (patch)
treefc0fa4408ec4561140c4a9a4c4290e5d4eb6def6 /Lib/distutils/tests
parentab5e17f8964bfb9b73566180e27410520d2391d4 (diff)
downloadcpython-dd7bef9bf56933851e68094ffc70f8f20bc6b036.zip
cpython-dd7bef9bf56933851e68094ffc70f8f20bc6b036.tar.gz
cpython-dd7bef9bf56933851e68094ffc70f8f20bc6b036.tar.bz2
reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r--Lib/distutils/tests/test_cygwinccompiler.py111
-rw-r--r--Lib/distutils/tests/test_emxccompiler.py33
-rwxr-xr-xLib/distutils/tests/test_extension.py78
-rw-r--r--Lib/distutils/tests/test_install.py173
-rw-r--r--Lib/distutils/tests/test_unixccompiler.py8
-rw-r--r--Lib/distutils/tests/test_util.py260
6 files changed, 11 insertions, 652 deletions
diff --git a/Lib/distutils/tests/test_cygwinccompiler.py b/Lib/distutils/tests/test_cygwinccompiler.py
deleted file mode 100644
index e97ac66..0000000
--- a/Lib/distutils/tests/test_cygwinccompiler.py
+++ /dev/null
@@ -1,111 +0,0 @@
-"""Tests for distutils.cygwinccompiler."""
-import unittest
-import sys
-import os
-import warnings
-import sysconfig
-
-from test.test_support import check_warnings, run_unittest
-from test.test_support import captured_stdout
-
-from distutils import cygwinccompiler
-from distutils.cygwinccompiler import (CygwinCCompiler, check_config_h,
- CONFIG_H_OK, CONFIG_H_NOTOK,
- CONFIG_H_UNCERTAIN, get_versions,
- get_msvcr, RE_VERSION)
-from distutils.util import get_compiler_versions
-from distutils.tests import support
-
-class CygwinCCompilerTestCase(support.TempdirManager,
- unittest.TestCase):
-
- def setUp(self):
- super(CygwinCCompilerTestCase, self).setUp()
- self.version = sys.version
- self.python_h = os.path.join(self.mkdtemp(), 'python.h')
- self.old_get_config_h_filename = sysconfig.get_config_h_filename
- sysconfig.get_config_h_filename = self._get_config_h_filename
-
- def tearDown(self):
- sys.version = self.version
- sysconfig.get_config_h_filename = self.old_get_config_h_filename
- super(CygwinCCompilerTestCase, self).tearDown()
-
- def _get_config_h_filename(self):
- return self.python_h
-
- def test_check_config_h(self):
-
- # check_config_h looks for "GCC" in sys.version first
- # returns CONFIG_H_OK if found
- sys.version = ('2.6.1 (r261:67515, Dec 6 2008, 16:42:21) \n[GCC '
- '4.0.1 (Apple Computer, Inc. build 5370)]')
-
- self.assertEquals(check_config_h()[0], CONFIG_H_OK)
-
- # then it tries to see if it can find "__GNUC__" in pyconfig.h
- sys.version = 'something without the *CC word'
-
- # if the file doesn't exist it returns CONFIG_H_UNCERTAIN
- self.assertEquals(check_config_h()[0], CONFIG_H_UNCERTAIN)
-
- # if it exists but does not contain __GNUC__, it returns CONFIG_H_NOTOK
- self.write_file(self.python_h, 'xxx')
- self.assertEquals(check_config_h()[0], CONFIG_H_NOTOK)
-
- # and CONFIG_H_OK if __GNUC__ is found
- self.write_file(self.python_h, 'xxx __GNUC__ xxx')
- self.assertEquals(check_config_h()[0], CONFIG_H_OK)
-
- def test_get_msvcr(self):
-
- # none
- sys.version = ('2.6.1 (r261:67515, Dec 6 2008, 16:42:21) '
- '\n[GCC 4.0.1 (Apple Computer, Inc. build 5370)]')
- self.assertEquals(get_msvcr(), None)
-
- # MSVC 7.0
- sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
- '[MSC v.1300 32 bits (Intel)]')
- self.assertEquals(get_msvcr(), ['msvcr70'])
-
- # MSVC 7.1
- sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
- '[MSC v.1310 32 bits (Intel)]')
- self.assertEquals(get_msvcr(), ['msvcr71'])
-
- # VS2005 / MSVC 8.0
- sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
- '[MSC v.1400 32 bits (Intel)]')
- self.assertEquals(get_msvcr(), ['msvcr80'])
-
- # VS2008 / MSVC 9.0
- sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
- '[MSC v.1500 32 bits (Intel)]')
- self.assertEquals(get_msvcr(), ['msvcr90'])
-
- # unknown
- sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
- '[MSC v.1999 32 bits (Intel)]')
- self.assertRaises(ValueError, get_msvcr)
-
-
- def test_get_version_deprecated(self):
- with check_warnings() as w:
- warnings.simplefilter("always")
- # make sure get_compiler_versions and get_versions
- # returns the same thing
- self.assertEquals(get_compiler_versions(), get_versions())
- # make sure using get_version() generated a warning
- self.assertEquals(len(w.warnings), 1)
- # make sure any usage of RE_VERSION will also
- # generate a warning, but till works
- version = RE_VERSION.search('1.2').group(1)
- self.assertEquals(version, '1.2')
- self.assertEquals(len(w.warnings), 2)
-
-def test_suite():
- return unittest.makeSuite(CygwinCCompilerTestCase)
-
-if __name__ == '__main__':
- run_unittest(test_suite())
diff --git a/Lib/distutils/tests/test_emxccompiler.py b/Lib/distutils/tests/test_emxccompiler.py
deleted file mode 100644
index d5e07dc..0000000
--- a/Lib/distutils/tests/test_emxccompiler.py
+++ /dev/null
@@ -1,33 +0,0 @@
-"""Tests for distutils.emxccompiler."""
-import unittest
-import sys
-import os
-import warnings
-
-from test.test_support import check_warnings, run_unittest
-from test.test_support import captured_stdout
-
-from distutils.emxccompiler import get_versions
-from distutils.util import get_compiler_versions
-from distutils.tests import support
-
-class EmxCCompilerTestCase(support.TempdirManager,
- unittest.TestCase):
-
- def test_get_version_deprecated(self):
- with check_warnings() as w:
- warnings.simplefilter("always")
- # make sure get_compiler_versions and get_versions
- # returns the same gcc
- gcc, ld, dllwrap = get_compiler_versions()
- emx_gcc, emx_ld = get_versions()
- self.assertEquals(gcc, emx_gcc)
-
- # make sure using get_version() generated a warning
- self.assertEquals(len(w.warnings), 1)
-
-def test_suite():
- return unittest.makeSuite(EmxCCompilerTestCase)
-
-if __name__ == '__main__':
- run_unittest(test_suite())
diff --git a/Lib/distutils/tests/test_extension.py b/Lib/distutils/tests/test_extension.py
deleted file mode 100755
index 0b5dfb8..0000000
--- a/Lib/distutils/tests/test_extension.py
+++ /dev/null
@@ -1,78 +0,0 @@
-"""Tests for distutils.extension."""
-import os
-import sys
-import unittest
-import warnings
-
-from test.test_support import check_warnings
-from distutils.extension import read_setup_file, Extension
-from distutils.tests.support import capture_warnings
-
-class ExtensionTestCase(unittest.TestCase):
-
- @capture_warnings
- def test_read_setup_file(self):
- # trying to read a Setup file
- # (sample extracted from the PyGame project)
- setup = os.path.join(os.path.dirname(__file__), 'Setup.sample')
-
- exts = read_setup_file(setup)
- names = [ext.name for ext in exts]
- names.sort()
-
- # here are the extensions read_setup_file should have created
- # out of the file
- wanted = ['_arraysurfarray', '_camera', '_numericsndarray',
- '_numericsurfarray', 'base', 'bufferproxy', 'cdrom',
- 'color', 'constants', 'display', 'draw', 'event',
- 'fastevent', 'font', 'gfxdraw', 'image', 'imageext',
- 'joystick', 'key', 'mask', 'mixer', 'mixer_music',
- 'mouse', 'movie', 'overlay', 'pixelarray', 'pypm',
- 'rect', 'rwobject', 'scrap', 'surface', 'surflock',
- 'time', 'transform']
-
- self.assertEquals(names, wanted)
-
- @unittest.skipIf(sys.flags.optimize >= 2,
- "Assertions are omitted with -O2 and above")
- def test_extension_init_assertions(self):
- # The first argument, which is the name, must be a string.
- self.assertRaises(AssertionError, Extension, 1, [])
-
- # the second argument, which is the list of files, must
- # be a list of strings
- self.assertRaises(AssertionError, Extension, 'name', 'file')
- self.assertRaises(AssertionError, Extension, 'name', ['file', 1])
-
- def test_extension_init(self):
- ext = Extension('name', [])
- self.assertEquals(ext.name, 'name')
-
-
- ext = Extension('name', ['file1', 'file2'])
- self.assertEquals(ext.sources, ['file1', 'file2'])
-
- # others arguments have defaults
- for attr in ('include_dirs', 'define_macros', 'undef_macros',
- 'library_dirs', 'libraries', 'runtime_library_dirs',
- 'extra_objects', 'extra_compile_args', 'extra_link_args',
- 'export_symbols', 'swig_opts', 'depends'):
- self.assertEquals(getattr(ext, attr), [])
-
- self.assertEquals(ext.language, None)
- self.assertEquals(ext.optional, None)
-
- # if there are unknown keyword options, warn about them
- with check_warnings() as w:
- warnings.simplefilter('always')
- ext = Extension('name', ['file1', 'file2'], chic=True)
-
- self.assertEquals(len(w.warnings), 1)
- self.assertEquals(str(w.warnings[0].message),
- "Unknown Extension options: 'chic'")
-
-def test_suite():
- return unittest.makeSuite(ExtensionTestCase)
-
-if __name__ == "__main__":
- unittest.main(defaultTest="test_suite")
diff --git a/Lib/distutils/tests/test_install.py b/Lib/distutils/tests/test_install.py
index 8e3e942..c834b91 100644
--- a/Lib/distutils/tests/test_install.py
+++ b/Lib/distutils/tests/test_install.py
@@ -1,27 +1,15 @@
"""Tests for distutils.command.install."""
import os
-import os.path
-import sys
import unittest
-import site
-import sysconfig
-from sysconfig import (get_scheme_names, _CONFIG_VARS, _INSTALL_SCHEMES,
- get_config_var, get_path)
-
-from test.test_support import captured_stdout
from distutils.command.install import install
-from distutils.command import install as install_module
from distutils.core import Distribution
-from distutils.errors import DistutilsOptionError
from distutils.tests import support
-class InstallTestCase(support.TempdirManager,
- support.EnvironGuard,
- support.LoggingSilencer,
- unittest.TestCase):
+
+class InstallTestCase(support.TempdirManager, unittest.TestCase):
def test_home_installation_scheme(self):
# This ensure two things:
@@ -38,23 +26,9 @@ class InstallTestCase(support.TempdirManager,
build_lib=os.path.join(builddir, "lib"),
)
-
-
- posix_prefix = _INSTALL_SCHEMES['posix_prefix']
- old_posix_prefix = posix_prefix['platinclude']
- posix_prefix['platinclude'] = \
- '{platbase}/include/python{py_version_short}'
-
- posix_home = _INSTALL_SCHEMES['posix_home']
- old_posix_home = posix_home['platinclude']
- posix_home['platinclude'] = '{base}/include/python'
- try:
- cmd = install(dist)
- cmd.home = destination
- cmd.ensure_finalized()
- finally:
- posix_home['platinclude'] = old_posix_home
- posix_prefix['platinclude'] = old_posix_prefix
+ cmd = install(dist)
+ cmd.home = destination
+ cmd.ensure_finalized()
self.assertEqual(cmd.install_base, destination)
self.assertEqual(cmd.install_platbase, destination)
@@ -73,143 +47,6 @@ class InstallTestCase(support.TempdirManager,
check_path(cmd.install_scripts, os.path.join(destination, "bin"))
check_path(cmd.install_data, destination)
- def test_user_site(self):
- # site.USER_SITE was introduced in 2.6
- if sys.version < '2.6':
- return
-
- # preparing the environement for the test
- self.old_user_base = get_config_var('userbase')
- self.old_user_site = get_path('purelib', '%s_user' % os.name)
- self.tmpdir = self.mkdtemp()
- self.user_base = os.path.join(self.tmpdir, 'B')
- self.user_site = os.path.join(self.tmpdir, 'S')
- _CONFIG_VARS['userbase'] = self.user_base
- scheme = _INSTALL_SCHEMES['%s_user' % os.name]
- scheme['purelib'] = self.user_site
-
- def _expanduser(path):
- if path[0] == '~':
- path = os.path.normpath(self.tmpdir) + path[1:]
- return path
- self.old_expand = os.path.expanduser
- os.path.expanduser = _expanduser
-
- try:
- # this is the actual test
- self._test_user_site()
- finally:
- _CONFIG_VARS['userbase'] = self.old_user_base
- scheme['purelib'] = self.old_user_site
- os.path.expanduser = self.old_expand
-
- def _test_user_site(self):
- schemes = get_scheme_names()
- for key in ('nt_user', 'posix_user', 'os2_home'):
- self.assertTrue(key in schemes)
-
- dist = Distribution({'name': 'xx'})
- cmd = install(dist)
- # making sure the user option is there
- options = [name for name, short, lable in
- cmd.user_options]
- self.assertTrue('user' in options)
-
- # setting a value
- cmd.user = 1
-
- # user base and site shouldn't be created yet
- self.assertTrue(not os.path.exists(self.user_base))
- self.assertTrue(not os.path.exists(self.user_site))
-
- # let's run finalize
- cmd.ensure_finalized()
-
- # now they should
- self.assertTrue(os.path.exists(self.user_base))
- self.assertTrue(os.path.exists(self.user_site))
-
- self.assertTrue('userbase' in cmd.config_vars)
- self.assertTrue('usersite' in cmd.config_vars)
-
- def test_handle_extra_path(self):
- dist = Distribution({'name': 'xx', 'extra_path': 'path,dirs'})
- cmd = install(dist)
-
- # two elements
- cmd.handle_extra_path()
- self.assertEquals(cmd.extra_path, ['path', 'dirs'])
- self.assertEquals(cmd.extra_dirs, 'dirs')
- self.assertEquals(cmd.path_file, 'path')
-
- # one element
- cmd.extra_path = ['path']
- cmd.handle_extra_path()
- self.assertEquals(cmd.extra_path, ['path'])
- self.assertEquals(cmd.extra_dirs, 'path')
- self.assertEquals(cmd.path_file, 'path')
-
- # none
- dist.extra_path = cmd.extra_path = None
- cmd.handle_extra_path()
- self.assertEquals(cmd.extra_path, None)
- self.assertEquals(cmd.extra_dirs, '')
- self.assertEquals(cmd.path_file, None)
-
- # three elements (no way !)
- cmd.extra_path = 'path,dirs,again'
- self.assertRaises(DistutilsOptionError, cmd.handle_extra_path)
-
- def test_finalize_options(self):
- dist = Distribution({'name': 'xx'})
- cmd = install(dist)
-
- # must supply either prefix/exec-prefix/home or
- # install-base/install-platbase -- not both
- cmd.prefix = 'prefix'
- cmd.install_base = 'base'
- self.assertRaises(DistutilsOptionError, cmd.finalize_options)
-
- # must supply either home or prefix/exec-prefix -- not both
- cmd.install_base = None
- cmd.home = 'home'
- self.assertRaises(DistutilsOptionError, cmd.finalize_options)
-
- # can't combine user with with prefix/exec_prefix/home or
- # install_(plat)base
- cmd.prefix = None
- cmd.user = 'user'
- self.assertRaises(DistutilsOptionError, cmd.finalize_options)
-
- def test_record(self):
-
- install_dir = self.mkdtemp()
- pkgdir, dist = self.create_dist()
-
- dist = Distribution()
- cmd = install(dist)
- dist.command_obj['install'] = cmd
- cmd.root = install_dir
- cmd.record = os.path.join(pkgdir, 'RECORD')
- cmd.ensure_finalized()
-
- cmd.run()
-
- # let's check the RECORD file was created with one
- # line (the egg info file)
- with open(cmd.record) as f:
- self.assertEquals(len(f.readlines()), 1)
-
- def _test_debug_mode(self):
- # this covers the code called when DEBUG is set
- old_logs_len = len(self.logs)
- install_module.DEBUG = True
- try:
- with captured_stdout() as stdout:
- self.test_record()
- finally:
- install_module.DEBUG = False
- self.assertTrue(len(self.logs) > old_logs_len)
def test_suite():
return unittest.makeSuite(InstallTestCase)
diff --git a/Lib/distutils/tests/test_unixccompiler.py b/Lib/distutils/tests/test_unixccompiler.py
index 6976dd5..3f233e2 100644
--- a/Lib/distutils/tests/test_unixccompiler.py
+++ b/Lib/distutils/tests/test_unixccompiler.py
@@ -1,8 +1,8 @@
"""Tests for distutils.unixccompiler."""
import sys
import unittest
-import sysconfig
+from distutils import sysconfig
from distutils.unixccompiler import UnixCCompiler
class UnixCCompilerTestCase(unittest.TestCase):
@@ -70,7 +70,7 @@ class UnixCCompilerTestCase(unittest.TestCase):
elif v == 'GNULD':
return 'yes'
sysconfig.get_config_var = gcv
- self.assertEqual(self.cc.rpath_foo(), '-Wl,--enable-new-dtags,-R/foo')
+ self.assertEqual(self.cc.rpath_foo(), '-Wl,-R/foo')
# GCC non-GNULD
sys.platform = 'bar'
@@ -91,7 +91,7 @@ class UnixCCompilerTestCase(unittest.TestCase):
elif v == 'GNULD':
return 'yes'
sysconfig.get_config_var = gcv
- self.assertEqual(self.cc.rpath_foo(), '-Wl,--enable-new-dtags,-R/foo')
+ self.assertEqual(self.cc.rpath_foo(), '-Wl,-R/foo')
# non-GCC GNULD
@@ -119,7 +119,7 @@ class UnixCCompilerTestCase(unittest.TestCase):
def gcv(v):
return 'xxx'
sysconfig.get_config_var = gcv
- self.assertEqual(self.cc.rpath_foo(), '-blibpath:/foo')
+ self.assertEqual(self.cc.rpath_foo(), '-R/foo')
def test_suite():
diff --git a/Lib/distutils/tests/test_util.py b/Lib/distutils/tests/test_util.py
index 348b42b..981ad00 100644
--- a/Lib/distutils/tests/test_util.py
+++ b/Lib/distutils/tests/test_util.py
@@ -1,267 +1,11 @@
"""Tests for distutils.util."""
-import os
import sys
import unittest
-from copy import copy
-from StringIO import StringIO
-import subprocess
-from sysconfig import get_config_vars, get_platform
from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError
-from distutils.util import (convert_path, change_root,
- check_environ, split_quoted, strtobool,
- rfc822_escape, get_compiler_versions,
- _find_exe_version, _MAC_OS_X_LD_VERSION,
- byte_compile)
-from distutils import util
-from distutils.tests import support
-from distutils.version import LooseVersion
+from distutils.util import byte_compile
-class FakePopen(object):
- test_class = None
- def __init__(self, cmd, shell, stdout, stderr):
- self.cmd = cmd.split()[0]
- exes = self.test_class._exes
- if self.cmd not in exes:
- # we don't want to call the system, returning an empty
- # output so it doesn't match
- self.stdout = StringIO()
- self.stderr = StringIO()
- else:
- self.stdout = StringIO(exes[self.cmd])
- self.stderr = StringIO()
-
-class UtilTestCase(support.EnvironGuard, unittest.TestCase):
-
- def setUp(self):
- super(UtilTestCase, self).setUp()
- # saving the environment
- self.name = os.name
- self.platform = sys.platform
- self.version = sys.version
- self.sep = os.sep
- self.join = os.path.join
- self.isabs = os.path.isabs
- self.splitdrive = os.path.splitdrive
- #self._config_vars = copy(sysconfig._config_vars)
-
- # patching os.uname
- if hasattr(os, 'uname'):
- self.uname = os.uname
- self._uname = os.uname()
- else:
- self.uname = None
- self._uname = None
- os.uname = self._get_uname
-
- # patching POpen
- self.old_find_executable = util.find_executable
- util.find_executable = self._find_executable
- self._exes = {}
- self.old_popen = subprocess.Popen
- self.old_stdout = sys.stdout
- self.old_stderr = sys.stderr
- FakePopen.test_class = self
- subprocess.Popen = FakePopen
-
- def tearDown(self):
- # getting back the environment
- os.name = self.name
- sys.platform = self.platform
- sys.version = self.version
- os.sep = self.sep
- os.path.join = self.join
- os.path.isabs = self.isabs
- os.path.splitdrive = self.splitdrive
- if self.uname is not None:
- os.uname = self.uname
- else:
- del os.uname
- #sysconfig._config_vars = copy(self._config_vars)
- util.find_executable = self.old_find_executable
- subprocess.Popen = self.old_popen
- sys.old_stdout = self.old_stdout
- sys.old_stderr = self.old_stderr
- super(UtilTestCase, self).tearDown()
-
- def _set_uname(self, uname):
- self._uname = uname
-
- def _get_uname(self):
- return self._uname
-
- def test_get_platform(self):
- platform = util.get_platform()
- self.assertEquals(platform, get_platform())
- util.set_platform('MyOwnPlatform')
- self.assertEquals('MyOwnPlatform', util.get_platform())
- util.set_platform(platform)
-
- def test_convert_path(self):
- # linux/mac
- os.sep = '/'
- def _join(path):
- return '/'.join(path)
- os.path.join = _join
-
- self.assertEquals(convert_path('/home/to/my/stuff'),
- '/home/to/my/stuff')
-
- # win
- os.sep = '\\'
- def _join(*path):
- return '\\'.join(path)
- os.path.join = _join
-
- self.assertRaises(ValueError, convert_path, '/home/to/my/stuff')
- self.assertRaises(ValueError, convert_path, 'home/to/my/stuff/')
-
- self.assertEquals(convert_path('home/to/my/stuff'),
- 'home\\to\\my\\stuff')
- self.assertEquals(convert_path('.'),
- os.curdir)
-
- def test_change_root(self):
- # linux/mac
- os.name = 'posix'
- def _isabs(path):
- return path[0] == '/'
- os.path.isabs = _isabs
- def _join(*path):
- return '/'.join(path)
- os.path.join = _join
-
- self.assertEquals(change_root('/root', '/old/its/here'),
- '/root/old/its/here')
- self.assertEquals(change_root('/root', 'its/here'),
- '/root/its/here')
-
- # windows
- os.name = 'nt'
- def _isabs(path):
- return path.startswith('c:\\')
- os.path.isabs = _isabs
- def _splitdrive(path):
- if path.startswith('c:'):
- return ('', path.replace('c:', ''))
- return ('', path)
- os.path.splitdrive = _splitdrive
- def _join(*path):
- return '\\'.join(path)
- os.path.join = _join
-
- self.assertEquals(change_root('c:\\root', 'c:\\old\\its\\here'),
- 'c:\\root\\old\\its\\here')
- self.assertEquals(change_root('c:\\root', 'its\\here'),
- 'c:\\root\\its\\here')
-
- # BugsBunny os (it's a great os)
- os.name = 'BugsBunny'
- self.assertRaises(DistutilsPlatformError,
- change_root, 'c:\\root', 'its\\here')
-
- # XXX platforms to be covered: os2, mac
-
- def test_check_environ(self):
- util._environ_checked = 0
- if 'HOME' in os.environ:
- del os.environ['HOME']
-
- # posix without HOME
- if os.name == 'posix': # this test won't run on windows
- check_environ()
- import pwd
- self.assertEquals(os.environ['HOME'], pwd.getpwuid(os.getuid())[5])
- else:
- check_environ()
-
- self.assertEquals(os.environ['PLAT'], get_platform())
- self.assertEquals(util._environ_checked, 1)
-
- def test_split_quoted(self):
- self.assertEquals(split_quoted('""one"" "two" \'three\' \\four'),
- ['one', 'two', 'three', 'four'])
-
- def test_strtobool(self):
- yes = ('y', 'Y', 'yes', 'True', 't', 'true', 'True', 'On', 'on', '1')
- no = ('n', 'no', 'f', 'false', 'off', '0', 'Off', 'No', 'N')
-
- for y in yes:
- self.assertTrue(strtobool(y))
-
- for n in no:
- self.assertTrue(not strtobool(n))
-
- def test_rfc822_escape(self):
- header = 'I am a\npoor\nlonesome\nheader\n'
- res = rfc822_escape(header)
- wanted = ('I am a%(8s)spoor%(8s)slonesome%(8s)s'
- 'header%(8s)s') % {'8s': '\n'+8*' '}
- self.assertEquals(res, wanted)
-
- def test_find_exe_version(self):
- # the ld version scheme under MAC OS is:
- # ^@(#)PROGRAM:ld PROJECT:ld64-VERSION
- #
- # where VERSION is a 2-digit number for major
- # revisions. For instance under Leopard, it's
- # currently 77
- #
- # Dots are used when branching is done.
- #
- # The SnowLeopard ld64 is currently 95.2.12
-
- for output, version in (('@(#)PROGRAM:ld PROJECT:ld64-77', '77'),
- ('@(#)PROGRAM:ld PROJECT:ld64-95.2.12',
- '95.2.12')):
- result = _MAC_OS_X_LD_VERSION.search(output)
- self.assertEquals(result.group(1), version)
-
- def _find_executable(self, name):
- if name in self._exes:
- return name
- return None
-
- def test_get_compiler_versions(self):
- # get_versions calls distutils.spawn.find_executable on
- # 'gcc', 'ld' and 'dllwrap'
- self.assertEquals(get_compiler_versions(), (None, None, None))
-
- # Let's fake we have 'gcc' and it returns '3.4.5'
- self._exes['gcc'] = 'gcc (GCC) 3.4.5 (mingw special)\nFSF'
- res = get_compiler_versions()
- self.assertEquals(str(res[0]), '3.4.5')
-
- # and let's see what happens when the version
- # doesn't match the regular expression
- # (\d+\.\d+(\.\d+)*)
- self._exes['gcc'] = 'very strange output'
- res = get_compiler_versions()
- self.assertEquals(res[0], None)
-
- # same thing for ld
- if sys.platform != 'darwin':
- self._exes['ld'] = 'GNU ld version 2.17.50 20060824'
- res = get_compiler_versions()
- self.assertEquals(str(res[1]), '2.17.50')
- self._exes['ld'] = '@(#)PROGRAM:ld PROJECT:ld64-77'
- res = get_compiler_versions()
- self.assertEquals(res[1], None)
- else:
- self._exes['ld'] = 'GNU ld version 2.17.50 20060824'
- res = get_compiler_versions()
- self.assertEquals(res[1], None)
- self._exes['ld'] = '@(#)PROGRAM:ld PROJECT:ld64-77'
- res = get_compiler_versions()
- self.assertEquals(str(res[1]), '77')
-
- # and dllwrap
- self._exes['dllwrap'] = 'GNU dllwrap 2.17.50 20060824\nFSF'
- res = get_compiler_versions()
- self.assertEquals(str(res[2]), '2.17.50')
- self._exes['dllwrap'] = 'Cheese Wrap'
- res = get_compiler_versions()
- self.assertEquals(res[2], None)
+class UtilTestCase(unittest.TestCase):
def test_dont_write_bytecode(self):
# makes sure byte_compile raise a DistutilsError