Commit 254f00a6 authored by Jérome Perrin's avatar Jérome Perrin

Add support to run tests directly from business templates



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16555 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 29af81de
...@@ -166,7 +166,7 @@ class ERP5TypeTestLoader(unittest.TestLoader): ...@@ -166,7 +166,7 @@ class ERP5TypeTestLoader(unittest.TestLoader):
return module.test_suite() return module.test_suite()
return unittest.TestLoader.loadTestsFromModule(self, module) return unittest.TestLoader.loadTestsFromModule(self, module)
def runUnitTestList(test_list) : def runUnitTestList(test_list):
if len(test_list) == 0 : if len(test_list) == 0 :
print "No test to run, exiting immediately." print "No test to run, exiting immediately."
return return
...@@ -212,12 +212,15 @@ def runUnitTestList(test_list) : ...@@ -212,12 +212,15 @@ def runUnitTestList(test_list) :
TestRunner = unittest.TextTestRunner TestRunner = unittest.TextTestRunner
suite = unittest.TestSuite() suite = unittest.TestSuite()
os.chdir(tests_home) # allow unit tests of our Products or business templates to be reached.
# allow unit tests of our Products to be reached.
from glob import glob from glob import glob
product_test_list = glob(products_home + os.sep + '*' + os.sep + 'tests') product_test_list = glob(os.path.join(
products_home, os.sep, '*', os.sep, 'tests'))
sys.path.extend(product_test_list) sys.path.extend(product_test_list)
bt5_path = os.environ.get('erp5_tests_bt5_path',
os.path.join(instance_home, 'bt5'))
bt5_test_list = glob(os.path.join(bt5_path, '*', 'TestTemplateItem'))
sys.path.extend(bt5_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
...@@ -243,8 +246,11 @@ def runUnitTestList(test_list) : ...@@ -243,8 +246,11 @@ def runUnitTestList(test_list) :
unittest.makeSuite = dummy_makeSuite unittest.makeSuite = dummy_makeSuite
PortalTestCase.setUp = dummy_setUp PortalTestCase.setUp = dummy_setUp
PortalTestCase.tearDown = dummy_tearDown PortalTestCase.tearDown = dummy_tearDown
suite = ERP5TypeTestLoader(save=save).loadTestsFromNames(test_list) suite = ERP5TypeTestLoader(save=save).loadTestsFromNames(test_list)
# change current directory to the test home, to create zLOG.log in this dir.
os.chdir(tests_home)
return TestRunner().run(suite) return TestRunner().run(suite)
def usage(stream, msg=None): def usage(stream, msg=None):
......
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