Rev 3211: Some cleanup. in file:///v/home/vila/src/bzr/experimental/selftest/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Sun Feb 10 20:23:07 GMT 2008
At file:///v/home/vila/src/bzr/experimental/selftest/
------------------------------------------------------------
revno: 3211
revision-id:v.ladeuil+lp at free.fr-20080210202303-quvxt6vx24bf3m0j
parent: v.ladeuil+lp at free.fr-20080209111045-v52cct05czkwth0l
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: selftest
timestamp: Sun 2008-02-10 21:23:03 +0100
message:
Some cleanup.
* bzrlib/tests/test_selftest.py:
Update tests.
* bzrlib/tests/__init__.py:
(TestIdList.is_module_name_used): Renamed to refers_to.
(TestIdList.test_in): Renamed to includes.
modified:
bzrlib/tests/TestUtil.py TestUtil.py-20050824080200-5f70140a2d938694
-------------- next part --------------
=== modified file 'bzrlib/tests/TestUtil.py'
--- a/bzrlib/tests/TestUtil.py 2008-01-07 16:47:46 +0000
+++ b/bzrlib/tests/TestUtil.py 2008-02-10 20:23:03 +0000
@@ -89,8 +89,13 @@
"""
result = self.suiteClass()
for name in names:
- module = _load_module_by_name(name)
- result.addTests(self.loadTestsFromModule(module))
+ result.addTests(self.loadTestsFromModuleName(name))
+ return result
+
+ def loadTestsFromModuleName(self, name):
+ result = self.suiteClass()
+ module = _load_module_by_name(name)
+ result.addTests(self.loadTestsFromModule(module))
return result
def loadTestsFromModule(self, module):
@@ -135,6 +140,25 @@
self.test_func_names[test_case_class] = test_fn_names
return test_fn_names
+
+class FilteredByModuleTestLoader(TestLoader):
+ """A test loader able to avoid importing unwanted modules."""
+
+ def __init__(exclude_module):
+ """Constructor.
+
+ :param exclude_module: a callable taking a module name as a
+ parameter returing False if the module should be loaded.
+ """
+ self.exclude_module = exclude_module
+
+ def loadTestsFromModuleName(self, name):
+ if not self.exclude_module(name):
+ return TestLoader.loadTestsFromModuleName(name)
+ else:
+ return self.suiteClass()
+
+
def _load_module_by_name(mod_name):
parts = mod_name.split('.')
module = __import__(mod_name)
More information about the bazaar-commits
mailing list