6c3bbdbef8fa8e1caa412beb83dd9a023f2e972f
Because the `savepoint` and `clear` calls are nested inside the `assertRaises` context, if one of them happens to throw *the exception we're looking for* the interpreter will jump back to the `with`, the `assertRaises` will swallow the exception (and count it as a success) and the function will end having not gone through a `yield`. This is rather frustrating to debug as it's easy to forget that a `with` is a control flow structure, leading to a seemingly impossible error. We can fix this by initializing and `__enter__`-ing the savepoint first, but doing this by hand is a bit iffy and not really future-proof as the addition of more fallible steps during the initialization phase of `_assertRaises` could lead to the savepoint not being properly disposed of. Furthermore once in the scope of the "actual" assertRaises we want the savepoint to unwind first (otherwise the savepoint won't be rolled back when the exception *we are expecting* gets raised). As it turns out `ExitStack` offers the solution to our woes though it's a bit tricky at first glance: while modifying the cleanup queue in-place is haram, `pop_all` allows moving cleanup callbacks from one queue to the next. This means we can first add the savepoint to one stack and get its errors (if any) correctly reported, cover the rest of the initialization, then move the savepoint from one stack to an other, in order to correctly order the coverage of the `yield` (and the userland code). closes odoo/odoo#87733 X-original-commit: b1cd4e4e3c918b4b08d27b30b1017fc898d4b08a Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
…
…
…
Odoo
Odoo is a suite of web based open source business apps.
The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...
Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.
Getting started with Odoo
For a standard installation please follow the Setup instructions from the documentation.
To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials
Languages
Python
49.6%
JavaScript
47.8%
SCSS
2%
CSS
0.3%
HTML
0.2%