Commit 5c8f4d3b authored by Jérome Perrin's avatar Jérome Perrin

get test suite using the default test_suite function, unless some class names

are specified on the command line.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8478 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fe219835
...@@ -98,7 +98,7 @@ def runUnitTestList(test_list) : ...@@ -98,7 +98,7 @@ def runUnitTestList(test_list) :
sys.path.extend((real_tests_home, tests_home)) sys.path.extend((real_tests_home, tests_home))
# Make sure that locally overridden python modules are used # Make sure that locally overridden python modules are used
sys.path.insert(0, os.path.join(real_instance_home, 'lib%spython' % os.sep)) sys.path.insert(0, os.path.join(real_instance_home, 'lib', 'python'))
# XXX Allowing to load modules from here is a wrong idea. use the above path # XXX Allowing to load modules from here is a wrong idea. use the above path
# instead. # instead.
...@@ -107,19 +107,26 @@ def runUnitTestList(test_list) : ...@@ -107,19 +107,26 @@ def runUnitTestList(test_list) :
# it is then possible to run the debugger by "import pdb; pdb.set_trace()" # it is then possible to run the debugger by "import pdb; pdb.set_trace()"
sys.path.insert(0, tests_framework_home) sys.path.insert(0, tests_framework_home)
filtered_tests_class_names = 0
for test in test_list: for test in test_list:
if ':' in test: if ':' in test:
test_module = test.split(':')[0] test_module = test.split(':')[0]
if test_module.endswith('.py'): if test_module.endswith('.py'):
test_module = test_module[:-3] test_module = test_module[:-3]
test_class_list = test.split(':')[1:] test_class_list = test.split(':')[1:]
filtered_tests_class_names = 1
else: else:
if test.endswith('.py'): if test.endswith('.py'):
test = test[:-3] test = test[:-3]
test_module = test test_module = test
test_class_list = None test_class_list = None
m = __import__(test_module) m = __import__(test_module)
for attr_name in dir(m) : if not filtered_tests_class_names and hasattr(m, 'test_suite'):
suite = m.test_suite()
else:
# dynamically create the test suite using class names passed on the
# command line.
for attr_name in dir(m):
attr = getattr(m, attr_name) attr = getattr(m, attr_name)
if (type(attr) == type(type)) and (hasattr(attr, '__module__')) and \ if (type(attr) == type(type)) and (hasattr(attr, '__module__')) and \
(attr.__module__ == test_module) : (attr.__module__ == test_module) :
......
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