From 77ec840cb00d9910cd7751fd17dda8f0806849b2 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 5 Jun 2012 11:52:10 +0200 Subject: [PATCH] [FIX] ir_values: fix a test where some value was hard-coded. bzr revid: vmt@openerp.com-20120605095210-0t5bmlyxrtnoqvr0 --- openerp/addons/base/tests/test_ir_values.py | 9 ++++++--- openerp/modules/module.py | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/tests/test_ir_values.py b/openerp/addons/base/tests/test_ir_values.py index b7ea0107776..b306e1f0929 100644 --- a/openerp/addons/base/tests/test_ir_values.py +++ b/openerp/addons/base/tests/test_ir_values.py @@ -54,7 +54,10 @@ class test_ir_values(common.TransactionCase): ir_values.set(self.cr, self.uid, 'action', 'tree_but_open', 'OnDblClick Action', ['unexisting_model'], 'ir.actions.act_window,10', isobject=True) ir_values.set(self.cr, self.uid, 'action', 'tree_but_open', 'OnDblClick Action 2', ['unexisting_model'], 'ir.actions.act_window,11', isobject=True) ir_values.set(self.cr, self.uid, 'action', 'client_action_multi', 'Side Wizard', ['unexisting_model'], 'ir.actions.act_window,12', isobject=True) - ir_values.set(self.cr, self.uid, 'action', 'client_print_multi', 'Nice Report', ['unexisting_model'], 'ir.actions.report.xml,45', isobject=True) + report_ids = self.registry('ir.actions.report.xml').search(self.cr, self.uid, [], {}) + reports = self.registry('ir.actions.report.xml').browse(self.cr, self.uid, report_ids, {}) + report_id = [report.id for report in reports if not report.groups_id][0] # assume at least one + ir_values.set(self.cr, self.uid, 'action', 'client_print_multi', 'Nice Report', ['unexisting_model'], 'ir.actions.report.xml,%s'%report_id, isobject=True) ir_values.set(self.cr, self.uid, 'action', 'client_action_relate', 'Related Stuff', ['unexisting_model'], 'ir.actions.act_window,14', isobject=True) # Replace one action binding to set a new name. @@ -86,7 +89,7 @@ class test_ir_values(common.TransactionCase): assert len(actions) == 1, "Mismatching number of bound actions" assert len(actions[0]) == 3, "Malformed action definition" assert actions[0][1] == 'Nice Report', 'Bound action does not match definition' - assert isinstance(actions[0][2], dict) and actions[0][2]['id'] == 45, 'Bound action does not match definition' + assert isinstance(actions[0][2], dict) and actions[0][2]['id'] == report_id, 'Bound action does not match definition' actions = ir_values.get(self.cr, self.uid, 'action', 'client_action_relate', ['unexisting_model']) assert len(actions) == 1, "Mismatching number of bound actions" @@ -96,4 +99,4 @@ class test_ir_values(common.TransactionCase): if __name__ == '__main__': - unittest2.main() \ No newline at end of file + unittest2.main() diff --git a/openerp/modules/module.py b/openerp/modules/module.py index e226b69a6fc..265a23190e5 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -493,7 +493,7 @@ def get_test_modules(module, submodule, explode): # It seems the module has no `tests` sub-module, no problem. pass else: - print 'Can not `import %s`.' % module + _logger.exception('Can not `import %s`.', module) return [] # Discover available test sub-modules. @@ -554,6 +554,7 @@ def run_unit_tests(module_name): """ import unittest2 ms = get_test_modules(module_name, '__fast_suite__', explode=False) + # TODO: No need to try again if the above call failed because of e.g. a syntax error. ms.extend(get_test_modules(module_name, '__sanity_checks__', explode=False)) suite = unittest2.TestSuite() for m in ms: