summaryrefslogtreecommitdiff
path: root/distutils2/tests
diff options
context:
space:
mode:
Diffstat (limited to 'distutils2/tests')
-rw-r--r--distutils2/tests/support.py6
-rw-r--r--distutils2/tests/test_command_build.py5
-rw-r--r--distutils2/tests/test_command_build_ext.py6
-rw-r--r--distutils2/tests/test_command_install_dist.py4
-rw-r--r--distutils2/tests/test_mixin2to3.py8
-rw-r--r--distutils2/tests/test_util.py4
6 files changed, 18 insertions, 15 deletions
diff --git a/distutils2/tests/support.py b/distutils2/tests/support.py
index 4852c54..366314d 100644
--- a/distutils2/tests/support.py
+++ b/distutils2/tests/support.py
@@ -63,8 +63,9 @@ __all__ = [
# misc. functions and decorators
'fake_dec', 'create_distribution', 'use_command',
'copy_xxmodule_c', 'fixup_build_ext',
+ 'requires_py26_min', 'skip_2to3_optimize',
# imported from this module for backport purposes
- 'unittest', 'requires_zlib', 'skip_2to3_optimize', 'skip_unless_symlink',
+ 'unittest', 'requires_zlib', 'skip_unless_symlink',
]
@@ -402,10 +403,11 @@ except ImportError:
skip_unless_symlink = unittest.skip(
'requires test.test_support.skip_unless_symlink')
-
skip_2to3_optimize = unittest.skipUnless(__debug__,
"2to3 doesn't work under -O")
+requires_py26_min = unittest.skipIf(sys.version_info[:2] < (2, 6),
+ 'requires Python 2.6 or higher')
requires_zlib = unittest.skipUnless(zlib, 'requires zlib')
diff --git a/distutils2/tests/test_command_build.py b/distutils2/tests/test_command_build.py
index 08bef58..3a926cd 100644
--- a/distutils2/tests/test_command_build.py
+++ b/distutils2/tests/test_command_build.py
@@ -26,7 +26,8 @@ class BuildTestCase(support.TempdirManager,
# build_platlib is 'build/lib.platform-x.x[-pydebug]'
# examples:
# build/lib.macosx-10.3-i386-2.7
- plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3])
+ pyversion = '%s.%s' % sys.version_info[:2]
+ plat_spec = '.%s-%s' % (cmd.plat_name, pyversion)
if hasattr(sys, 'gettotalrefcount'):
self.assertTrue(cmd.build_platlib.endswith('-pydebug'))
plat_spec += '-pydebug'
@@ -41,7 +42,7 @@ class BuildTestCase(support.TempdirManager,
self.assertEqual(cmd.build_temp, wanted)
# build_scripts is build/scripts-x.x
- wanted = os.path.join(cmd.build_base, 'scripts-' + sys.version[0:3])
+ wanted = os.path.join(cmd.build_base, 'scripts-' + pyversion)
self.assertEqual(cmd.build_scripts, wanted)
# executable is os.path.normpath(sys.executable)
diff --git a/distutils2/tests/test_command_build_ext.py b/distutils2/tests/test_command_build_ext.py
index 5a6f77a..7b04cca 100644
--- a/distutils2/tests/test_command_build_ext.py
+++ b/distutils2/tests/test_command_build_ext.py
@@ -19,12 +19,12 @@ class BuildExtTestCase(support.TempdirManager,
def setUp(self):
super(BuildExtTestCase, self).setUp()
self.tmp_dir = self.mkdtemp()
- if sys.version > "2.6":
+ if sys.version_info[:2] >= (2, 6):
self.old_user_base = site.USER_BASE
site.USER_BASE = self.mkdtemp()
def tearDown(self):
- if sys.version > "2.6":
+ if sys.version_info[:2] >= (2, 6):
site.USER_BASE = self.old_user_base
super(BuildExtTestCase, self).tearDown()
@@ -85,7 +85,7 @@ class BuildExtTestCase(support.TempdirManager,
# make sure we get some library dirs under solaris
self.assertGreater(len(cmd.library_dirs), 0)
- @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')
+ @support.requires_py26_min
def test_user_site(self):
dist = Distribution({'name': 'xx'})
cmd = build_ext(dist)
diff --git a/distutils2/tests/test_command_install_dist.py b/distutils2/tests/test_command_install_dist.py
index 572ca2a..02f962b 100644
--- a/distutils2/tests/test_command_install_dist.py
+++ b/distutils2/tests/test_command_install_dist.py
@@ -72,7 +72,7 @@ class InstallTestCase(support.TempdirManager,
check_path(cmd.install_scripts, os.path.join(destination, "bin"))
check_path(cmd.install_data, destination)
- @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')
+ @support.requires_py26_min
def test_user_site(self):
# test install with --user
# preparing the environment for the test
@@ -172,7 +172,7 @@ class InstallTestCase(support.TempdirManager,
cmd.home = 'home'
self.assertRaises(PackagingOptionError, cmd.finalize_options)
- if sys.version >= '2.6':
+ if sys.version_info[:2] >= (2, 6):
# can't combine user with with prefix/exec_prefix/home or
# install_(plat)base
cmd.prefix = None
diff --git a/distutils2/tests/test_mixin2to3.py b/distutils2/tests/test_mixin2to3.py
index 719a152..bfd5102 100644
--- a/distutils2/tests/test_mixin2to3.py
+++ b/distutils2/tests/test_mixin2to3.py
@@ -29,9 +29,9 @@ class Mixin2to3TestCase(support.TempdirManager,
converted = fp.read()
finally:
fp.close()
- self.assertMultiLineEqual(wanted, converted)
+ self.assertMultiLineEqual(converted, wanted)
- @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')
+ @support.requires_py26_min
def test_conversion(self):
# check that code and doctests get converted
self.check('''\
@@ -57,7 +57,7 @@ class Mixin2to3TestCase(support.TempdirManager,
''', # 2to3 adds a newline here
files=[self.filename])
- @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')
+ @support.requires_py26_min
def test_doctests_conversion(self):
# check that doctest files are converted
self.check('''\
@@ -75,7 +75,7 @@ class Mixin2to3TestCase(support.TempdirManager,
''',
doctests=[self.filename])
- @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')
+ @support.requires_py26_min
def test_additional_fixers(self):
# make sure the fixers argument works
self.check("""\
diff --git a/distutils2/tests/test_util.py b/distutils2/tests/test_util.py
index 6833905..c08517e 100644
--- a/distutils2/tests/test_util.py
+++ b/distutils2/tests/test_util.py
@@ -417,7 +417,7 @@ class UtilTestCase(support.EnvironRestorer,
self.assertRaises(ImportError, resolve_name, 'a.b.Spam')
self.assertRaises(ImportError, resolve_name, 'a.b.c.Spam')
- @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')
+ @support.requires_py26_min
@support.skip_2to3_optimize
def test_run_2to3_on_code(self):
content = "print 'test'"
@@ -432,7 +432,7 @@ class UtilTestCase(support.EnvironRestorer,
file_handle.close()
self.assertEqual(new_content, converted_content)
- @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')
+ @support.requires_py26_min
@support.skip_2to3_optimize
def test_run_2to3_on_doctests(self):
# to check if text files containing doctests only get converted.