Commit 420f81ea authored by Alexandre Boeglin's avatar Alexandre Boeglin

This script runs unittests presents in $(instance_home)/tests.

It can be called from the ZMI (actually, with a os.popen() call) or directly from the shell.
It does not require framework.py or anything outside of ERP5Type/tests to run UnitTests that are in another directory.
Directories containing scripts just have to be added to sys.path.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2277 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ffbf69b8
#!/usr/bin/python
#
# Runs the tests passed on the command line
#
import os, sys
def getUnitTestFile() :
return os.path.abspath(__file__)
# site specific variables
instance_home = '/home/%s/zope' % os.environ['USER']
software_home = '/usr/lib/zope/lib/python'
tests_home = os.path.join(instance_home, 'tests')
tests_framework_home = os.path.dirname(os.path.abspath(__file__))
if '__INSTANCE_HOME' not in globals().keys() :
__INSTANCE_HOME = instance_home
def runUnitTestList(test_list) :
os.environ['INSTANCE_HOME'] = instance_home
os.environ['SOFTWARE_HOME'] = software_home
os.environ['COPY_OF_INSTANCE_HOME'] = instance_home
os.environ['COPY_OF_SOFTWARE_HOME'] = software_home
execfile(os.path.join(tests_framework_home, 'framework.py'))
import unittest
TestRunner = unittest.TextTestRunner
suite = unittest.TestSuite()
os.chdir(tests_home)
for test in test_list:
m = __import__(test)
if hasattr(m, 'test_suite'):
suite.addTest(m.test_suite())
TestRunner().run(suite)
if __name__ == '__main__' :
runUnitTestList(test_list=sys.argv[1:])
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