Skip to content

Commit 246ff67

Browse files
committed
[IMP] testing.py: raise specific exceptions
Raising bare `Exception` objects is an anti-pattern. This commit fix the `TRY002` ruff rule. Part-of: #32
1 parent 39ebd99 commit 246ff67

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/testing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def change_version(version_str):
218218
def version_decorator(obj):
219219
match = VERSION_RE.match(version_str)
220220
if not match:
221-
raise Exception("change_version decorator must be in format [saas(-|~)<int:version>.<int:subversion:int>]")
221+
raise ValueError("change_version decorator must be in format [saas(-|~)<int:version>.<int:subversion:int>]")
222222
(_, version, sub_version) = match.groups()
223223
obj.change_version = (int(version), int(sub_version))
224224
return obj
@@ -322,7 +322,7 @@ def commit(self):
322322
if self.dbname == config["log_db"].split("/")[-1]:
323323
self._cnx.commit()
324324
else:
325-
raise Exception("Commit are forbidden in integrity cases")
325+
raise RuntimeError("Commit is forbidden in integrity cases")
326326

327327
patcher = patch.object(odoo.sql_db.Cursor, "commit", commit)
328328
patcher.start()

0 commit comments

Comments
 (0)