summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier-Do <xdo@odoo.com>2019-11-12 08:31:14 +0000
committerXavier-Do <xdo@odoo.com>2019-11-13 11:05:14 +0000
commitc403aec2aa6d0a60dd1c10ab43becdbfa52fab22 (patch)
treef678768e9e6f4ed0ba19c9f39dcc16285eda2c53
parenteb2f0aabcfd8c3764f7bca1c99448dadc266727e (diff)
[IMP] core,test_access_rights: improve exept_orm stringification
In most case, except_orm.value is empty, leading to a str representation of the args, which is a repr of each element of the tuple in the case of exept_orm: (repr(name), repr(value)) -> ('name', None) In this case, the None value is just noise and the name will be repr causing "'" to be escaped and replacing carriage return by "\n" making it difficult to read and to compare.
-rw-r--r--odoo/addons/test_access_rights/tests/test_feedback.py16
-rw-r--r--odoo/exceptions.py6
2 files changed, 14 insertions, 8 deletions
diff --git a/odoo/addons/test_access_rights/tests/test_feedback.py b/odoo/addons/test_access_rights/tests/test_feedback.py
index 40515026f3c..2dc4a00d7a5 100644
--- a/odoo/addons/test_access_rights/tests/test_feedback.py
+++ b/odoo/addons/test_access_rights/tests/test_feedback.py
@@ -189,11 +189,11 @@ class TestIRRuleFeedback(Feedback):
p = self.env['test_access_right.parent'].create({'obj_id': self.record.id})
- self.assertRaisesRegex(
+ with self.assertRaisesRegex(
AccessError,
- r"Implicitly accessed through \\'Object for testing related access rights\\' \(test_access_right.parent\)\.",
- p.with_user(self.user).write, {'val': 1}
- )
+ r"Implicitly accessed through 'Object for testing related access rights' \(test_access_right.parent\)\.",
+ ):
+ p.with_user(self.user).write({'val': 1})
def test_locals(self):
self.env.ref('base.group_no_one').write(
@@ -308,11 +308,11 @@ Note: this might be a multi-company issue.
p = self.env['test_access_right.parent'].create({'obj_id': self.record.id})
p.flush()
p.invalidate_cache()
- self.assertRaisesRegex(
+ with self.assertRaisesRegex(
AccessError,
- r"Implicitly accessed through \\'Object for testing related access rights\\' \(test_access_right.parent\)\.",
- lambda: p.with_user(self.user).val
- )
+ r"Implicitly accessed through 'Object for testing related access rights' \(test_access_right.parent\)\.",
+ ):
+ p.with_user(self.user).val
class TestFieldGroupFeedback(Feedback):
diff --git a/odoo/exceptions.py b/odoo/exceptions.py
index b3cc6b48f1e..17a3d89ede8 100644
--- a/odoo/exceptions.py
+++ b/odoo/exceptions.py
@@ -29,6 +29,12 @@ class except_orm(Exception):
self.value = value
self.args = (name, value)
+ def __str__(self):
+ if not self.value:
+ return str(self.name)
+ else:
+ return super().__str__()
+
class UserError(except_orm):
"""Generic error managed by the client.