-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
[16.0][FIX] add addClassCleanup in testcase #1763
base: 16.0
Are you sure you want to change the base?
[16.0][FIX] add addClassCleanup in testcase #1763
Conversation
Hi @lmarion-source, @lmignon, @rousseldenis, |
@chaule97 I agreed on name change because it is duplicated from base module. But the errors you point to are not related to that. Please highlight the real problem you want to solve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution but the name of a test class should never cause problem when running tests... IMO the diagnostic is not right. Moreover when you change the name of a class into a module named as the call, the module must also be renamed....
@chaule97 https://github.com/OCA/product-attribute/blob/16.0/base_product_mass_addition/tests/test_product_mass_addition.py#L21 This is the real error. Missing a teardown(). See https://github.com/OCA/odoo-test-helper/blob/master/README.rst You do the fix ? |
Or @legalsylvain ? |
Thanks. I will continue it |
Feel free to add the teardown in this PR. |
Thanks everyone, I have added teardown |
thanks @chaule97 ! |
@classmethod | ||
def tearDownClass(cls): | ||
cls.loader.restore_registry() | ||
return super().tearDownClass() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to register the call to the restore_registry
method in the list of cleanup methods to execute when all the tests into the class are executed just after the fake registry is backed up
cls.loader.backup_registry()
cls.addClassCleanup(cls.loader.restore_registry)
In this way, even if an exception occurs into your setup, the registry will be cleaned up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lmignon Isn't it supported by test class ?
If not, odoo-test-helper documentation should be adapted too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lmignon I have changed it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my last comment
a314805
to
8ca0c24
Compare
@@ -6,7 +6,7 @@ | |||
from odoo.tests.common import TransactionCase | |||
|
|||
|
|||
class TestABCClassificationProfile(TransactionCase): | |||
class TestABCClassificationProfileSaleStock(TransactionCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chaule97 This change is useless but if you change the classname you must change the filename.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have renamed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this change is useless and we must avoid useless changes. Is-it really a problem for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, I have removed this commit. I remember Odoo 17 have issue when it have duplicate testcase class name. I think that it was fixed in version 18.0
8ca0c24
to
62d38ed
Compare
62d38ed
to
5baf68a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this fix!
This PR has the |
The test class in the
product_abc_classification_sale_stock
module has the same name as a test class inproduct_abc_classification
, which is causing an error in GitHub CI in #1561, #1683