Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

Re: Odoo Test framework and rollback issue

by
DEC, Yann Papouin
- 23/11/2023 14:47:38
Thank you all for your feedback.

So I will (when possible) try to split my tests and re-arrange their content so that the exception assertions are (is) processed at the very end.
Anyway, I will always add the self.cr.savepoint() in the with context (looking at the Odoo 14.0 code, clear_upon_failure is automatically called by assertRaises).

--
Yann PAPOUIN


Le ven. 17 nov. 2023 à 13:42, Pedro M. Baeza <notifications@odoo-community.org> a écrit :
Holger Brunn has pointed to me that there's a way to recover properly in SavepointCase tests after a raise:


You have to add the reset_on_failure to your `with` statement. And it seems that since v15, the savepoint is enough.

Anyway, think twice about piling a lot of asserts in the same test, being raise or not, as having an early failure makes you to iterate several times until having a pass one, although testing flows is usual to have that sequential asserts.

Thanks for the extra insights, Holger!

Regards.

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

Reference