From ff2f188d200689e59bddcdcb441df8be4e8319a4 Mon Sep 17 00:00:00 2001 From: mge-odoo Date: Tue, 7 Feb 2017 17:23:13 +0100 Subject: [IMP] tests: allow post-install tests to play real transactions Move the post-install tests execution outside `Registry.new`, and add a flag on class `HttpCase` to enable/disable the registry "test mode". This allows a test to run actual transactions that will reload the registry, which may be used to test the creation of `ir.model` instances, etc. --- odoo/modules/loading.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'odoo/modules/loading.py') diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index e9744844841..0f9987f62eb 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -19,8 +19,7 @@ import odoo.modules.registry import odoo.tools as tools from odoo import api, SUPERUSER_ID -from odoo.modules.module import adapt_version, initialize_sys_path, \ - load_openerp_module, runs_post_install +from odoo.modules.module import adapt_version, initialize_sys_path, load_openerp_module _logger = logging.getLogger(__name__) _test_logger = logging.getLogger('odoo.tests') @@ -416,18 +415,9 @@ def load_modules(db, force_demo=False, status=None, update_module=False): for model in env.values(): model._register_hook() - # STEP 9: Run the post-install tests + # STEP 9: save installed/updated modules for post-install tests + registry.updated_modules += processed_modules cr.commit() - t0 = time.time() - t0_sql = odoo.sql_db.sql_counter - if odoo.tools.config['test_enable']: - if update_module: - cr.execute("SELECT name FROM ir_module_module WHERE state='installed' and name = ANY(%s)", (processed_modules,)) - else: - cr.execute("SELECT name FROM ir_module_module WHERE state='installed'") - for module_name in cr.fetchall(): - report.record_result(odoo.modules.module.run_unit_tests(module_name[0], cr.dbname, position=runs_post_install)) - _logger.log(25, "All post-tested in %.2fs, %s queries", time.time() - t0, odoo.sql_db.sql_counter - t0_sql) finally: cr.close() -- cgit v1.2.3