Commit 696739a1 authored by PJ Eby's avatar PJ Eby

Added ``test_loader`` keyword to support custom test loaders.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4043430
parent f4505e41
......@@ -41,27 +41,34 @@ setup(
packages = find_packages(),
package_data = {'setuptools':['*.exe']},
py_modules = ['pkg_resources', 'easy_install', 'site'],
zip_safe = False, # We want 'python -m easy_install' to work, for now :(
entry_points = {
"distutils.commands" : [
"%(cmd)s = setuptools.command.%(cmd)s:%(cmd)s" % locals()
for cmd in SETUP_COMMANDS
],
"distutils.setup_keywords": [
"eager_resources = setuptools.dist:assert_string_list",
"namespace_packages = setuptools.dist:check_nsp",
"extras_require = setuptools.dist:check_extras",
"install_requires = setuptools.dist:check_requirements",
"tests_require = setuptools.dist:check_requirements",
"entry_points = setuptools.dist:check_entry_points",
"test_suite = setuptools.dist:check_test_suite",
"zip_safe = setuptools.dist:assert_bool",
"eager_resources = setuptools.dist:assert_string_list",
"namespace_packages = setuptools.dist:check_nsp",
"extras_require = setuptools.dist:check_extras",
"install_requires = setuptools.dist:check_requirements",
"tests_require = setuptools.dist:check_requirements",
"entry_points = setuptools.dist:check_entry_points",
"test_suite = setuptools.dist:check_test_suite",
"zip_safe = setuptools.dist:assert_bool",
"package_data = setuptools.dist:check_package_data",
"exclude_package_data = setuptools.dist:check_package_data",
"include_package_data = setuptools.dist:assert_bool",
"dependency_links = setuptools.dist:assert_string_list",
"dependency_links = setuptools.dist:assert_string_list",
"test_loader = setuptools.dist:check_importable",
],
"egg_info.writers": [
"PKG-INFO = setuptools.command.egg_info:write_pkg_info",
"requires.txt = setuptools.command.egg_info:write_requirements",
......@@ -72,14 +79,17 @@ setup(
"depends.txt = setuptools.command.egg_info:warn_depends_obsolete",
"dependency_links.txt = setuptools.command.egg_info:overwrite_arg",
],
"console_scripts":
["easy_install = setuptools.command.easy_install:main",
"console_scripts": [
"easy_install = setuptools.command.easy_install:main",
"easy_install-%s = setuptools.command.easy_install:main"
% sys.version[:3]
% sys.version[:3]
],
"setuptools.file_finders":
["svn_cvs = setuptools.command.sdist:_default_revctrl"]
},
classifiers = [f.strip() for f in """
Development Status :: 3 - Alpha
Intended Audience :: Developers
......@@ -106,16 +116,6 @@ setup(
......
......@@ -10,6 +10,7 @@ namespace_packages = setuptools.dist:check_nsp
test_suite = setuptools.dist:check_test_suite
eager_resources = setuptools.dist:assert_string_list
zip_safe = setuptools.dist:assert_bool
test_loader = setuptools.dist:check_importable
tests_require = setuptools.dist:check_requirements
[setuptools.file_finders]
......
......@@ -362,6 +362,27 @@ unless you need the associated ``setuptools`` feature.
are run, but only downloaded to the project's setup directory if they're
not already installed locally.
``test_loader``
If you would like to use a different way of finding tests to run than what
setuptools normally uses, you can specify a module name and class name in
this argument. The named class must be instantiable with no arguments, and
its instances must support the ``loadTestsFromNames()`` method as defined
in the Python ``unittest`` module's ``TestLoader`` class. Setuptools will
pass only one test "name" in the `names` argument: the value supplied for
the ``test_suite`` argument. The loader you specify may interpret this
string in any way it likes, as there are no restrictions on what may be
contained in a ``test_suite`` string.
The module name and class name must be separated by a ``:``; the default
value of this argument is ``"setuptools.command.test:ScanningLoader"``. If
you want to use the default ``unittest`` behavior instead, you can specify
``"unittest:TestLoader"`` as your ``test_loader`` argument instead. This
will prevent automatic scanning of submodules and subpackages.
The module and class you specify here may be contained in another package,
as long as you use the ``tests_require`` option to ensure that the package
containing the loader class is available when the ``test`` command is run.
``eager_resources``
A list of strings naming resources that should be extracted together, if
any of them is needed, or if any C extensions included in the project are
......@@ -2471,6 +2492,8 @@ Release Notes/Change History
----------------------------
0.6a11
* Added ``test_loader`` keyword to support custom test loaders
* Added ``setuptools.file_finders`` entry point group to allow implementing
revision control plugins.
......
......@@ -51,11 +51,10 @@ class test(Command):
"Test suite to run (e.g. 'some_module.test_suite')"),
]
test_suite = None
test_module = None
def initialize_options(self):
pass
self.test_suite = None
self.test_module = None
self.test_loader = None
def finalize_options(self):
......@@ -74,9 +73,10 @@ class test(Command):
if self.verbose:
self.test_args.insert(0,'--verbose')
if self.test_loader is None:
self.test_loader = getattr(self.distribution,'test_loader',None)
if self.test_loader is None:
self.test_loader = "setuptools.command.test:ScanningLoader"
......@@ -111,13 +111,13 @@ class test(Command):
dist = Distribution(path_item, metadata, project_name=ei_cmd.egg_name)
working_set.add(dist)
require(str(dist.as_requirement()))
loader_ep = EntryPoint.parse("x="+self.test_loader)
loader_class = loader_ep.load(require=False)
unittest.main(
None, None, [unittest.__file__]+self.test_args,
testLoader = ScanningLoader()
testLoader = loader_class()
)
......@@ -28,15 +28,15 @@ _Distribution = _get_unpatched(_Distribution)
sequence = tuple, list
def check_importable(dist, attr, value):
try:
ep = pkg_resources.EntryPoint.parse('x='+value)
assert not ep.extras
except (TypeError,ValueError,AttributeError,AssertionError):
raise DistutilsSetupError(
"%r must be importable 'module:attrs' string (got %r)"
% (attr,value)
)
def assert_string_list(dist, attr, value):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment