-
Notifications
You must be signed in to change notification settings - Fork 23.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] tests: fix remaining patcher in python 3.10.12 #137215
Conversation
Using freezetime to decorate a TestCase can have strange effects. It looks like an override but monkeypatching the setUpClass/tearDownClass. It started breaking between python 3.10.6 and 3.10.12. See pr message for more details.
FWIW there's also freeze_time class decorators in mrp (to... today???), account_peppol, purchase_stock, sale, and a bunch of others, which I'd assume are also affected. edit: semgrep config for catching all them pokemans: rules:
- id: search
message: found hits
severity: INFO
languages: [python]
patterns:
- pattern: |
@freezegun.freeze_time(...)
class $C:
... |
robodoo r+ |
Yes good catch, it may be a good idea to forbid that since it can be bug prone
Did it with a regexe |
@Xavier-Do @d-fence because this PR has multiple commits, I need to know how to merge it:
|
@robodoo rebase-ff |
Merge method set to rebase and fast-forward. |
Using freezetime to decorate a TestCase can have strange effects. It looks like an override but monkeypatching the setUpClass/tearDownClass. It started breaking between python 3.10.6 and 3.10.12. See pr message for more details. closes #137215 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
While deploying runbot 200-204 an error started to occur on TestEquipement
https://runbot.odoo.com/runbot/build/51753527
And also in the lunch single module
https://runbot.odoo.com/runbot/build/51708103
This is caused by a
freeze_time
on the previous executed class,TestAlarm
(actually any class inheriting fromodoo.addons.lunch.tests.common.TestsCommon
)It looks like the issue appeared between 3.10.6 and 3.10.12 (maybe because of python/cpython#99699): _class_cleanups is now on the TestCase. This is still unsure since we have a custom version of TestCase, could be a strange interaction.
Could be related to spulec/freezegun#485
Switching the class decorator inside the setupClass fixes the issue
Freezetime code managing decorator on TestCase as a reference: