ms = submodules
elif submodule == '__fast_suite__':
# `suite` was used before the 6.1 release instead of `fast_suite`.
- ms = fast_suite if fast_suite else getattr(m, 'suite', None)
- if ms is None:
+ ms = fast_suite if hasattr(m, 'fast_suite') else getattr(m, 'suite', None)
+ if not ms:
if explode:
print 'The module `%s` has no defined test suite.' % (module,)
show_submodules_and_exit()
ms = []
elif submodule == '__sanity_checks__':
ms = checks
- if ms is None:
+ if not ms:
if explode:
print 'The module `%s` has no defined sanity checks.' % (module,)
show_submodules_and_exit()
import openerp
config = openerp.tools.config
+ config.load()
+
config['db_name'] = args.database
if args.port:
config['xmlrpc_port'] = int(args.port)
- config['admin_passwd'] = 'admin'
- config['db_password'] = 'a2aevl8w' # TODO from .openerpserverrc
- config['addons_path'] = args.addons.replace(':',',')
+
if args.addons:
- args.addons = args.addons.split(':')
+ args.addons = args.addons.replace(':',',').split(',')
else:
args.addons = []
+ # ensure no duplication in addons paths
+ args.addons = list(set(args.addons))
+ config['addons_path'] = ','.join(args.addons)
+
import logging
openerp.netsvc.init_alternative_logger()
logging.getLogger('openerp').setLevel(logging.CRITICAL)
else:
test_modules = get_test_modules(module, submodule, explode=True)
- # Run the test suite.
+ print 'Test modules:'
+ for test_module in test_modules:
+ print ' ', test_module.__name__
+ print
+ sys.stdout.flush()
+
if not args.dry_run:
suite = unittest2.TestSuite()
for test_module in test_modules:
r = unittest2.TextTestRunner(verbosity=2).run(suite)
if r.errors or r.failures:
sys.exit(1)
- else:
- print 'Test modules:'
- for test_module in test_modules:
- print ' ', test_module.__name__
def add_parser(subparsers):
parser = subparsers.add_parser('run-tests',