Replies: 1 comment 1 reply
-
Interesting! What about decorating test methods? (Which btw is better from my POV in any case 😉 ) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just wanted to warn the wider community about a little corner problem I found recently with freezegun.
There's definitely something weird in the way it patches
setUpClass
or other classmethods.In short, the class-level cleanups are bound to a different in-memory object. This produces that a class decorated with
@freezegun.freeze_time(some_date)
losses class cleanups. A particularly important one is the one that closes the cursor. Thus, these classes leave a dangling cursor after exercising all tests within.This can be or not a problem, depending on what happens after the tests are run. If Odoo just finishes, no problem; the cursor will get reaped by other means. But if you keep testing other modules whose installation means a DB lock in some way, you'll get to clunky, hard-to-diagnose Postgres locks.
This was notified upstream in spulec/freezegun#485 but:
requirements.txt
files.So, the most sensible approach for us here downstream at OCA, for now, is to replace such decorators like I did on OCA/sale-workflow#2747.
Take this example as a rule of thumb:
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions