diff --git a/odoo/addons/base/tests/test_test_suite.py b/odoo/addons/base/tests/test_test_suite.py index 89d1d9177a046d804fa814a47794c4e6f41496a2..a1267434af12976428998c5fa9c70b0ab3bd88c8 100644 --- a/odoo/addons/base/tests/test_test_suite.py +++ b/odoo/addons/base/tests/test_test_suite.py @@ -18,6 +18,7 @@ _logger = logging.getLogger(__name__) class TestTestSuite(TestCase): test_tags = {'standard', 'at_install'} test_module = 'base' + test_sequence = 0 def test_test_suite(self): """ Check that OdooSuite handles unittest.TestCase correctly. """ diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index 2cdd39ba9cf52ffaa160ff7ff25b7a292fb57889..3f9b40204bb9e14abb946312f00799708bf21605 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -254,7 +254,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, if tools.config.options['test_enable'] and (needs_update or not updating): env = api.Environment(cr, SUPERUSER_ID, {}) loader = odoo.tests.loader - suite = loader.make_suite(module_name, 'at_install') + suite = loader.make_suite([module_name], 'at_install') if suite.countTestCases(): if not needs_update: registry.setup_models(cr) diff --git a/odoo/service/server.py b/odoo/service/server.py index b28ed6ebecdf9434bd5a5908feb0cadbfbea6346..800161662f33afb26546235dd16baf3124a40476 100644 --- a/odoo/service/server.py +++ b/odoo/service/server.py @@ -1221,9 +1221,8 @@ def preload_registries(dbnames): _logger.info("Starting post tests") tests_before = registry._assertion_report.testsRun with odoo.api.Environment.manage(): - for module_name in module_names: - result = loader.run_suite(loader.make_suite(module_name, 'post_install'), module_name) - registry._assertion_report.update(result) + result = loader.run_suite(loader.make_suite(module_names, 'post_install')) + registry._assertion_report.update(result) _logger.info("%d post-tests in %.2fs, %s queries", registry._assertion_report.testsRun - tests_before, time.time() - t0, diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 0717a2e65ebfc2e7feef1c2c77565e1c9e4e9e1d..ab56fe7cfb6a757eb978e7cbea134e31422158fb 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -298,6 +298,7 @@ class MetaCase(type): cls.test_tags = {'standard', 'at_install'} cls.test_module = cls.__module__.split('.')[2] cls.test_class = cls.__name__ + cls.test_sequence = 0 class BaseCase(TreeCase, MetaCase('DummyCase', (object,), {})): diff --git a/odoo/tests/loader.py b/odoo/tests/loader.py index e435aa98c823537ac30ff0cc74559575b2666e6b..36e35e39f3bece773da51a42aaae4d6ddb9dbf8e 100644 --- a/odoo/tests/loader.py +++ b/odoo/tests/loader.py @@ -65,24 +65,25 @@ def _get_upgrade_test_modules(module): yield pymod -def make_suite(module_name, position='at_install'): - mods = get_test_modules(module_name) +def make_suite(module_names, position='at_install'): """ Creates a test suite for all the tests in the specified module, filtered by the provided ``position`` and the current test tags - :param str module_name: module to load tests from + :param list[str] module_names: modules to load tests from :param str position: "at_install" or "post_install" """ config_tags = TagsSelector(tools.config['test_tags']) position_tag = TagsSelector(position) - return OdooSuite( + tests = ( t - for m in mods + for module_name in module_names + for m in get_test_modules(module_name) for t in unwrap_suite(unittest.TestLoader().loadTestsFromModule(m)) if position_tag.check(t) and config_tags.check(t) ) + return OdooSuite(sorted(tests, key=lambda t: t.test_sequence)) -def run_suite(suite, module_name): +def run_suite(suite, module_name=None): # avoid dependency hell from ..modules import module module.current_test = module_name