From 5ae6f02e45168ef95d65c1956cea8b90218d8941 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Tue, 3 Mar 2020 13:49:53 +0000 Subject: [PATCH] [IMP] tests: scan upgrade path for additionnal tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A future upgrades improvement will be to add tests in upgrades modules. This small imp will scan in upgrade for some tests, specific tooling will be added to upgrade repository in odoo/upgrade#878 closes odoo/odoo#47030 X-original-commit: 59b5a03bdf7ae1ad8851a67d278edc31a26a96a8 Signed-off-by: Xavier Dollé (xdo) --- odoo/modules/module.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/odoo/modules/module.py b/odoo/modules/module.py index 191a45e9e8e..b5a513e19fc 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -357,7 +357,19 @@ def get_test_modules(module): """ Return a list of module for the addons potentially containing tests to feed unittest.TestLoader.loadTestsFromModule() """ # Try to import the module - modpath = 'odoo.addons.' + module + results = _get_tests_modules('odoo.addons', module) + + try: + importlib.import_module('odoo.upgrade.%s' % module) + except ImportError: + pass + else: + results += _get_tests_modules('odoo.upgrade', module) + + return results + +def _get_tests_modules(path, module): + modpath = '%s.%s' % (path, module) try: mod = importlib.import_module('.tests', modpath) except ImportError as e: # will also catch subclass ModuleNotFoundError of P3.6