From 92903e22f893f569d4cce0214b4adef82c2fe825 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 23 Jul 2020 08:13:50 +0000 Subject: [IMP] core: reporting after tests Currently there are a few issues with testing reporting (at the command-line): 1. there is a global report after at_install tests, but it gets "scrolled off" by long post_install tests, and is thus easy to miss 2. with test tags, it's easy to fat finger a typo and run 0 tests, which look like everything's running fine (no failure) To improve this, print a global report at shutdown (in `--stop-after-init` mode if tests are enabled) which recapitulates the test results *and prints a warning if no tests were run at all*. Also update the reporting collection to make this more reliable: * have `run_unit_tests` return `None` if it has run no tests, the assertion reporting machinery counts this as neither success nor failure which is exactly what we want * have load_test only report a success *if files were actually loaded* (by having `load_data` return that information) Task 2301268 closes odoo/odoo#54812 Signed-off-by: Xavier Morel (xmo) --- odoo/modules/loading.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'odoo/modules/loading.py') diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index af2cbe72f20..03c04003275 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -33,6 +33,8 @@ def load_data(cr, idref, mode, kind, package, report): noupdate is False, unless it is demo data or it is csv data in init mode. + :returns: Whether a file was loaded + :rtype: bool """ def _get_files_of_kind(kind): @@ -57,6 +59,7 @@ def load_data(cr, idref, mode, kind, package, report): ) return files + filename = None try: if kind in ('demo', 'test'): threading.currentThread().testing = True @@ -70,6 +73,7 @@ def load_data(cr, idref, mode, kind, package, report): if kind in ('demo', 'test'): threading.currentThread().testing = False + return bool(filename) def load_demo(cr, package, idref, mode, report=None): """ @@ -130,8 +134,8 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, def load_test(idref, mode): cr.execute("SAVEPOINT load_test_data_file") try: - load_data(cr, idref, mode, 'test', package, report) - return True + # return `None` if `load_data` didn't load any file + return load_data(cr, idref, mode, 'test', package, report) or None except Exception: _test_logger.exception( 'module %s: an exception occurred in a test', package.name) -- cgit v1.2.3