Skip to content
Snippets Groups Projects
Commit 86ba0197 authored by Raphael Collet's avatar Raphael Collet
Browse files

[FIX] tests: make self.assertRaises() return the expected object

parent 908252ec
No related branches found
No related tags found
No related merge requests found
......@@ -111,10 +111,12 @@ class TestACL(common.TransactionCase):
# 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()
......
......@@ -108,9 +108,9 @@ class BaseCase(unittest2.TestCase):
@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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment