Commit 9c637fe6 authored by Alexandre Boeglin's avatar Alexandre Boeglin

It is now possible to run Unit Tests of our Products from this script.

the Class is now the only thing required in the Unit Test file.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2285 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c8bce6f9
...@@ -30,10 +30,18 @@ def runUnitTestList(test_list) : ...@@ -30,10 +30,18 @@ def runUnitTestList(test_list) :
os.chdir(tests_home) os.chdir(tests_home)
# allow unit tests of our Products to be reached.
products_home = os.path.join(instance_home, 'Products')
from glob import glob
product_test_list = glob(products_home + os.sep + '*' + os.sep + 'tests')
sys.path += product_test_list
for test in test_list: for test in test_list:
m = __import__(test) m = __import__(test)
if hasattr(m, 'test_suite'): for attr_name in dir(m) :
suite.addTest(m.test_suite()) attr = getattr(m, attr_name)
if (type(attr) == type(type)) and (hasattr(attr, '__module__')) and (attr.__module__ == test) :
suite.addTest(unittest.makeSuite(attr))
TestRunner().run(suite) TestRunner().run(suite)
......
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