From 3a369e15c2f435074c1c252cf41cb1d044ed6aae Mon Sep 17 00:00:00 2001 From: "Laetitia Gangloff (Acsone)" Date: Thu, 8 Aug 2013 16:36:22 +0200 Subject: [PATCH] test: correct some try/except test bzr revid: laetitia.gangloff@acsone.eu-20130808143622-7kk0p7ve786kg1yd --- addons/account/test/account_bank_statement.yml | 3 ++- addons/account/test/account_supplier_invoice.yml | 6 ++++-- addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/account/test/account_bank_statement.yml b/addons/account/test/account_bank_statement.yml index cbd35be438a..9b74fe8d347 100644 --- a/addons/account/test/account_bank_statement.yml +++ b/addons/account/test/account_bank_statement.yml @@ -67,9 +67,10 @@ Then I cancel Bank Statements and verifies that it raises a warning - !python {model: account.bank.statement}: | + from openerp.osv import osv try: self.button_cancel(cr, uid, [ref("account_bank_statement_0")]) assert False, "An exception should have been raised, the journal should not let us cancel moves!" - except Exception: + except osv.except_osv: # exception was raised as expected, as the journal does not allow cancelling moves pass diff --git a/addons/account/test/account_supplier_invoice.yml b/addons/account/test/account_supplier_invoice.yml index 02c3d367050..2c36b6751a9 100644 --- a/addons/account/test/account_supplier_invoice.yml +++ b/addons/account/test/account_supplier_invoice.yml @@ -73,14 +73,16 @@ I cancel the account move which is in posted state and verifies that it gives warning message - !python {model: account.move}: | + from openerp.osv import osv inv_obj = self.pool.get('account.invoice') inv = inv_obj.browse(cr, uid, ref('account_invoice_supplier0')) try: mov_cancel = self.button_cancel(cr, uid, [inv.move_id.id], {'lang': u'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'journal_type': 'purchase', 'active_ids': [ref('menu_action_invoice_tree2')], 'type': 'in_invoice', 'active_id': ref('menu_action_invoice_tree2')}) - except Exception, e: - assert e, 'Warning message has not been raised' + assert False, "This should never happen!" + except osv.except_osv, e: + pass - I verify that 'Period Sum' and 'Year sum' of the tax code are the expected values - diff --git a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml index 0dfeee54879..3c178728b6f 100644 --- a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml +++ b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml @@ -61,12 +61,13 @@ !python {model: hr_timesheet_sheet.sheet}: | uid = ref('base.user_root') import netsvc + from openerp.osv import osv try: self.button_confirm(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {"active_ids": [ref("hr_timesheet_sheet.menu_act_hr_timesheet_sheet_form")],"active_id": ref("hr_timesheet_sheet.menu_act_hr_timesheet_sheet_form"), }) - assert True, "The validation of the timesheet was unexpectedly accepted despite the 2:30 hours of difference" - except: + assert False, "The validation of the timesheet was unexpectedly accepted despite the 2:30 hours of difference" + except osv.except_osv, e: pass - I Modified the timesheet record and make the difference less than 1 hour.