odoo-local/docs/Overriding tests.md

1.1 KiB

Odoo : Overriding native tests

Based on information founded here - Adapted to fit in one file, works in Odoo 15

Inheriting the Class

Identify the class with tests to override and declare a class inheriting it, in the tests folder of your module

# file : tests/test_to_override.py

# -*- coding: utf-8 -*-

from odoo.addons.module.tests.test_to_override import TestToOverride
from odoo.tests import tagged

@tagged('whatever')
class TestToOverrideInherited(TestToOverride):

    def test_function_overriding(self):
        #testing

Disable native tests

Even with this system, native tests will still be ran. To disable them, you need to void the functions :

@tagged('whatever')
class TestToOverrideInherited(TestToOverride):
    @unittest.skip('Overriden test')
    def void(self: TestToOverride):
        pass

    # disable tests - do not disable a test without writing another one, testing is important!
    TestToOverride.test_function_to_override = void