summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/tests
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-09-17 01:31:51 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-09-17 01:31:51 (GMT)
commit7724a6c10c56a1b14b4933de368e672eae840f47 (patch)
tree1b3bd60ab9b79bd018cbc942a8e12140b2e18576 /Lib/packaging/tests
parent37ccd6f794539e0678b7a7ad938e571cc73e106c (diff)
downloadcpython-7724a6c10c56a1b14b4933de368e672eae840f47.zip
cpython-7724a6c10c56a1b14b4933de368e672eae840f47.tar.gz
cpython-7724a6c10c56a1b14b4933de368e672eae840f47.tar.bz2
Packaging cleanup: remove conditionals for < 2.6 support.
PEP 370 features and sys.dont_write_bytecode are always available in 3.3; the distutils2 backport still has the conditionals. I also renamed an internal misnamed method and fixed a few things (“packaging2” name, stray print, unused import, fd leak).
Diffstat (limited to 'Lib/packaging/tests')
-rw-r--r--Lib/packaging/tests/test_command_build_ext.py8
-rw-r--r--Lib/packaging/tests/test_command_build_py.py2
-rw-r--r--Lib/packaging/tests/test_command_install_dist.py12
-rw-r--r--Lib/packaging/tests/test_command_install_lib.py11
-rw-r--r--Lib/packaging/tests/test_mixin2to3.py3
-rw-r--r--Lib/packaging/tests/test_util.py4
6 files changed, 7 insertions, 33 deletions
diff --git a/Lib/packaging/tests/test_command_build_ext.py b/Lib/packaging/tests/test_command_build_ext.py
index 59d09bf..52dfa31 100644
--- a/Lib/packaging/tests/test_command_build_ext.py
+++ b/Lib/packaging/tests/test_command_build_ext.py
@@ -18,18 +18,13 @@ class BuildExtTestCase(support.TempdirManager,
support.LoggingCatcher,
unittest.TestCase):
def setUp(self):
- # Create a simple test environment
- # Note that we're making changes to sys.path
super(BuildExtTestCase, self).setUp()
self.tmp_dir = self.mkdtemp()
self.old_user_base = site.USER_BASE
site.USER_BASE = self.mkdtemp()
def tearDown(self):
- # Get everything back to normal
- if sys.version > "2.6":
- site.USER_BASE = self.old_user_base
-
+ site.USER_BASE = self.old_user_base
super(BuildExtTestCase, self).tearDown()
def test_build_ext(self):
@@ -94,7 +89,6 @@ 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')
def test_user_site(self):
dist = Distribution({'name': 'xx'})
cmd = build_ext(dist)
diff --git a/Lib/packaging/tests/test_command_build_py.py b/Lib/packaging/tests/test_command_build_py.py
index 243a863..4eeb34e 100644
--- a/Lib/packaging/tests/test_command_build_py.py
+++ b/Lib/packaging/tests/test_command_build_py.py
@@ -99,8 +99,6 @@ class BuildPyTestCase(support.TempdirManager,
os.chdir(cwd)
sys.stdout = old_stdout
- @unittest.skipUnless(hasattr(sys, 'dont_write_bytecode'),
- 'sys.dont_write_bytecode not supported')
def test_dont_write_bytecode(self):
# makes sure byte_compile is not used
pkg_dir, dist = self.create_dist()
diff --git a/Lib/packaging/tests/test_command_install_dist.py b/Lib/packaging/tests/test_command_install_dist.py
index 8f90aff..808b568 100644
--- a/Lib/packaging/tests/test_command_install_dist.py
+++ b/Lib/packaging/tests/test_command_install_dist.py
@@ -72,7 +72,6 @@ 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')
def test_user_site(self):
# test install with --user
# preparing the environment for the test
@@ -173,12 +172,11 @@ class InstallTestCase(support.TempdirManager,
cmd.home = 'home'
self.assertRaises(PackagingOptionError, cmd.finalize_options)
- if sys.version >= '2.6':
- # can't combine user with with prefix/exec_prefix/home or
- # install_(plat)base
- cmd.prefix = None
- cmd.user = 'user'
- self.assertRaises(PackagingOptionError, 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(PackagingOptionError, cmd.finalize_options)
def test_old_record(self):
# test pre-PEP 376 --record option (outside dist-info dir)
diff --git a/Lib/packaging/tests/test_command_install_lib.py b/Lib/packaging/tests/test_command_install_lib.py
index b46f3bd..d36120b 100644
--- a/Lib/packaging/tests/test_command_install_lib.py
+++ b/Lib/packaging/tests/test_command_install_lib.py
@@ -7,13 +7,6 @@ from packaging.command.install_lib import install_lib
from packaging.compiler.extension import Extension
from packaging.errors import PackagingOptionError
-try:
- no_bytecode = sys.dont_write_bytecode
- bytecode_support = True
-except AttributeError:
- no_bytecode = False
- bytecode_support = False
-
class InstallLibTestCase(support.TempdirManager,
support.LoggingCatcher,
@@ -40,7 +33,7 @@ class InstallLibTestCase(support.TempdirManager,
cmd.finalize_options()
self.assertEqual(cmd.optimize, 2)
- @unittest.skipIf(no_bytecode, 'byte-compile not supported')
+ @unittest.skipIf(sys.dont_write_bytecode, 'byte-compile not supported')
def test_byte_compile(self):
pkg_dir, dist = self.create_dist()
cmd = install_lib(dist)
@@ -89,8 +82,6 @@ class InstallLibTestCase(support.TempdirManager,
# get_input should return 2 elements
self.assertEqual(len(cmd.get_inputs()), 2)
- @unittest.skipUnless(bytecode_support,
- 'sys.dont_write_bytecode not supported')
def test_dont_write_bytecode(self):
# makes sure byte_compile is not used
pkg_dir, dist = self.create_dist()
diff --git a/Lib/packaging/tests/test_mixin2to3.py b/Lib/packaging/tests/test_mixin2to3.py
index 926f754..14a7487 100644
--- a/Lib/packaging/tests/test_mixin2to3.py
+++ b/Lib/packaging/tests/test_mixin2to3.py
@@ -9,7 +9,6 @@ class Mixin2to3TestCase(support.TempdirManager,
support.LoggingCatcher,
unittest.TestCase):
- @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')
def test_convert_code_only(self):
# used to check if code gets converted properly.
code = "print 'test'"
@@ -26,7 +25,6 @@ class Mixin2to3TestCase(support.TempdirManager,
self.assertEqual(expected, converted)
- @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')
def test_doctests_only(self):
# used to check if doctests gets converted properly.
doctest = textwrap.dedent('''\
@@ -57,7 +55,6 @@ class Mixin2to3TestCase(support.TempdirManager,
self.assertEqual(expected, converted)
- @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')
def test_additional_fixers(self):
# used to check if use_2to3_fixers works
code = 'type(x) is not T'
diff --git a/Lib/packaging/tests/test_util.py b/Lib/packaging/tests/test_util.py
index c3d91aa..2872458 100644
--- a/Lib/packaging/tests/test_util.py
+++ b/Lib/packaging/tests/test_util.py
@@ -319,8 +319,6 @@ class UtilTestCase(support.EnvironRestorer,
res = get_compiler_versions()
self.assertEqual(res[2], None)
- @unittest.skipUnless(hasattr(sys, 'dont_write_bytecode'),
- 'sys.dont_write_bytecode not supported')
def test_dont_write_bytecode(self):
# makes sure byte_compile raise a PackagingError
# if sys.dont_write_bytecode is True
@@ -407,7 +405,6 @@ class UtilTestCase(support.EnvironRestorer,
finally:
sys.path.remove(tmp_dir)
- @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')
def test_run_2to3_on_code(self):
content = "print 'test'"
converted_content = "print('test')"
@@ -422,7 +419,6 @@ 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')
def test_run_2to3_on_doctests(self):
# to check if text files containing doctests only get converted.
content = ">>> print 'test'\ntest\n"