I have some customized modules which change the default workflow, thus have to re-write related unit tests. First, I monkey patched one crm
module unit test without any issue.
The original crm
unit test: test_crm_ui.py on GitHub.
My monkey patch in a customized module:
import odoo.addons.crm.tests.test_crm_ui
@odoo.tests.tagged('post_install', '-at_install')
class TestUi(odoo.addons.crm.tests.test_crm_ui.TestUi):
def test_01_crm_tour(self):
pass
# ...
odoo.addons.crm.tests.test_crm_ui.TestUi = TestUi
Which worked.
Then I need to monkey patch all unit tests in sale_mrp
module. test_multistep_manufacturing.py
for example: original on GitHub.
First I tried below, similar to what I did to crm
.
import odoo.addons.sale_mrp.tests.test_multistep_manufacturing
class ReplaceTestMultistepManufacturing(odoo.addons.sale_mrp.tests.test_multistep_manufacturing.TestMultistepManufacturing):
def setUp(self):
pass
# ...
def test_00_manufacturing_step_one(self):
pass
# ...
odoo.addons.sale_mrp.tests.test_multistep_manufacturing.TestMultistepManufacturing = ReplaceTestMultistepManufacturing
Which did not work, maybe the actual module was not really patched. Then I tried below.
from odoo.addons.sale_mrp.tests import test_multistep_manufacturing
class ReplaceTestMultistepManufacturing(test_multistep_manufacturing.TestMultistepManufacturing):
def setUp(self):
pass
# ...
def test_00_manufacturing_step_one(self):
pass
# ...
test_multistep_manufacturing.TestMultistepManufacturing = ReplaceTestMultistepManufacturing
Which also did not work. Actually two attempts resulted the same - both the new test and the original test was run.
Am I doing monkey patch wrong or I need to do something special in Odoo? Thanks!