# accessing fields must no raise exceptions...
part.name
# ... except if they are restricted
- with self.assertRaises(openerp.exceptions.AccessError):
+ with self.assertRaises(openerp.osv.orm.except_orm) as cm:
with mute_logger('openerp.models'):
part.email
+ self.assertEqual(cm.exception.args[0], 'AccessError')
+
if __name__ == '__main__':
unittest2.main()
@contextmanager
def _assertRaises(self, exception):
""" Context manager that clears the environment upon failure. """
- with super(BaseCase, self).assertRaises(exception):
+ with super(BaseCase, self).assertRaises(exception) as cm:
with self.env.clear_upon_failure():
- yield
+ yield cm
def assertRaises(self, exception, func=None, *args, **kwargs):
if func: