summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/command/test.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2012-06-24 04:07:41 (GMT)
committerÉric Araujo <merwok@netwok.org>2012-06-24 04:07:41 (GMT)
commit859aad6a36262383b98ddd45fe3253a882b87ce8 (patch)
tree1cc50af4fc88c650fe997a2e72f5f26d92a1986c /Lib/packaging/command/test.py
parentdc44f55cc9dc1d016799362c344958baab328ff4 (diff)
downloadcpython-859aad6a36262383b98ddd45fe3253a882b87ce8.zip
cpython-859aad6a36262383b98ddd45fe3253a882b87ce8.tar.gz
cpython-859aad6a36262383b98ddd45fe3253a882b87ce8.tar.bz2
Remove packaging from the standard library.
Distutils2 will live on on PyPI and be included in the stdlib when it is ready. See discussion starting at http://mail.python.org/pipermail/python-dev/2012-June/120430.html
Diffstat (limited to 'Lib/packaging/command/test.py')
-rw-r--r--Lib/packaging/command/test.py80
1 files changed, 0 insertions, 80 deletions
diff --git a/Lib/packaging/command/test.py b/Lib/packaging/command/test.py
deleted file mode 100644
index 4d5348f..0000000
--- a/Lib/packaging/command/test.py
+++ /dev/null
@@ -1,80 +0,0 @@
-"""Run the project's test suite."""
-
-import os
-import sys
-import logging
-import unittest
-
-from packaging import logger
-from packaging.command.cmd import Command
-from packaging.database import get_distribution
-from packaging.errors import PackagingOptionError
-from packaging.util import resolve_name
-
-
-class test(Command):
-
- description = "run the project's test suite"
-
- user_options = [
- ('suite=', 's',
- "test suite to run (for example: 'some_module.test_suite')"),
- ('runner=', None,
- "test runner to be called."),
- ('tests-require=', None,
- "list of distributions required to run the test suite."),
- ]
-
- def initialize_options(self):
- self.suite = None
- self.runner = None
- self.tests_require = []
-
- def finalize_options(self):
- self.build_lib = self.get_finalized_command("build").build_lib
- for requirement in self.tests_require:
- if get_distribution(requirement) is None:
- logger.warning("test dependency %s is not installed, "
- "tests may fail", requirement)
- if (not self.suite and not self.runner and
- self.get_ut_with_discovery() is None):
- raise PackagingOptionError(
- "no test discovery available, please give a 'suite' or "
- "'runner' option or install unittest2")
-
- def get_ut_with_discovery(self):
- if hasattr(unittest.TestLoader, "discover"):
- return unittest
- else:
- try:
- import unittest2
- return unittest2
- except ImportError:
- return None
-
- def run(self):
- prev_syspath = sys.path[:]
- try:
- # build release
- build = self.reinitialize_command('build')
- self.run_command('build')
- sys.path.insert(0, build.build_lib)
-
- # XXX maybe we could pass the verbose argument of pysetup here
- logger = logging.getLogger('packaging')
- verbose = logger.getEffectiveLevel() >= logging.DEBUG
- verbosity = verbose + 1
-
- # run the tests
- if self.runner:
- resolve_name(self.runner)()
- elif self.suite:
- runner = unittest.TextTestRunner(verbosity=verbosity)
- runner.run(resolve_name(self.suite)())
- elif self.get_ut_with_discovery():
- ut = self.get_ut_with_discovery()
- test_suite = ut.TestLoader().discover(os.curdir)
- runner = ut.TextTestRunner(verbosity=verbosity)
- runner.run(test_suite)
- finally:
- sys.path[:] = prev_syspath