Skip to Content
Menu
This question has been flagged
4611 Views

I have a problem with post install test and i want to Monkey Patch it like this..


import addons.product.tests.test_product_attribute_value_config
from addons.product.tests.test_product_attribute_value_config import TestProductAttributeValueSetup
from odoo.tests import tagged

print(TestProductAttributeValueSetup)
print(addons.product.tests.test_product_attribute_value_config.TestProductAttributeValueConfig.test_clear_caches)
print("START")
@tagged('post_install', '-at_install')
class TestProductAttributeValueConfig(TestProductAttributeValueSetup):
print("IN Class")
def test_clear_caches(self):
print("IN method")
return

print("OUT")
addons.product.tests.test_product_attribute_value_config.TestProductAttributeValueConfig.test_clear_caches\
= TestProductAttributeValueConfig.test_clear_caches
print("STOP")


Here is output of my prints

<class 'addons.product.tests.test_product_attribute_value_config.TestProductAttributeValueSetup'>
<function TestProductAttributeValueConfig.test_clear_caches at 0x7f680f0c6d90>
START
IN Class
OUT
STOP

But test still fails, as my money patch is not working. How can i make it work?


2020-02-14 09:20:23,851 840 ERROR test_60 odoo.addons.product.tests.test_product_attribute_value_config: ERROR: test_clear_caches (odoo.addons.product.tests.test_product_attribute_value_config.TestProductAttributeValueConfig)
2020-02-14 09:20:23,851 840 ERROR test_60 odoo.addons.product.tests.test_product_attribute_value_config: ` The goal of this test is to make sure the cache is invalidated when it should be.
2020-02-14 09:20:23,851 840 ERROR test_60 odoo.addons.product.tests.test_product_attribute_value_config: Traceback (most recent call last):
2020-02-14 09:20:23,851 840 ERROR test_60 odoo.addons.product.tests.test_product_attribute_value_config: ` File "/home/antonp/workspace/Odoo12/addons/product/tests/test_product_attribute_value_config.py", line 494, in test_clear_caches
2020-02-14 09:20:23,851 840 ERROR test_60 odoo.addons.product.tests.test_product_attribute_value_config: ` self.env['product.product'].browse(variant_id).unlink()
2020-02-14 09:20:23,851 840 ERROR test_60 odoo.addons.product.tests.test_product_attribute_value_config: ` File "/home/antonp/workspace/Odoo12/addons/product/tests/test_variants.py", line 781, in unlink
2020-02-14 09:20:23,851 840 ERROR test_60 odoo.addons.product.tests.test_product_attribute_value_config: ` raise Exception('just')
2020-02-14 09:20:23,851 840 ERROR test_60 odoo.addons.product.tests.test_product_attribute_value_config: ` Exception: just

Avatar
Discard
Related Posts Replies Views Activity
2
Dec 23
11994
0
Oct 23
33
3
Oct 23
787
1
Oct 23
569
1
Aug 23
979